title: MaxMind IP Lookup Speed with Python API
body: <p>I'm building a script to process web server logs, and I'm trying to incorporate MaxMinds's IP dataset (<a href="http://dev.maxmind.com/geoip/legacy/geolite/" rel="nofollow">http://dev.maxmind.com/geoip/legacy/geolite/</a>) into the script in order to get the country the hit is coming from.</p>
  
  <p>Currently, my script works fine when I just have it extract the information I want, however when I try to add IP lookup's it slows down - a lot - by about 1800%.  So, I'm curious if this has something to do with my code or if there is a way I can speed this up.</p>
  
  <p>For example, when I run the following code extracting date and ip address, for this experiment it took about 6.5 seconds.</p>
  
  <pre><code>extractedData = []
  
  for log in logList:
      ip = log[-1]
      date = log[0]
      dateIP = [date, ip]
      extractedData.append(dateIP)
  </code></pre>
  
  <p>When I add pyGeoIP and try to incorporate the country code it slows down.  The following code took 2 mintues and 7seonds to run.</p>
  
  <pre><code>extractedData = []
  
  gi = pygeoip.GeoIP('/path/to/GeoIP.dat') 
  
  for log in logList:
      ip = log[-1]
      country = gi.country_name_by_addr(ip)
      date = log[0]
      dateCountry = [date, country]
      extractedData.append(dateCountry)
  </code></pre>
  
  <p>So, is there a way to speed this up since this look up will slow to process down too much.</p>
  
  <p>Thanks!</p>