geoip2fast
GeoIP2Fast is the fastest GeoIP2 country/city/asn lookup library that supports IPv4 and IPv6. A search takes less than 0.00003 seconds. It has its own data file updated twice a week with Maxmind-Geolite2-CSV, supports IPv4/IPv6 and is Pure Python!
What it is and what it does
GeoIP2Fast is a pure-Python geolocation library that maps IP addresses to geographic and network information using local binary data files. It loads Maxmind GeoLite2 data into memory and performs lookups via binary search on ordered IP ranges, returning country codes, city names, ASN names, and CIDR blocks for both IPv4 and IPv6 addresses. The library requires no external dependencies or network calls—only the Python file and a .dat.gz data file.
The package ships with a small country-level IPv4 database, but city and IPv6 variants must be downloaded separately or generated from Maxmind CSV files using the included geoip2dat.py tool. Data files are updated twice weekly. The library supports Python 3.7 through 3.13 and PyPy3, runs on Linux, Windows, and macOS, and is designed for applications that need fast, offline geolocation without external service dependencies.
Use it for:
- Geoblock or route traffic based on IP country origin in web applications or APIs.
- Enrich server logs or analytics with geolocation data without making external API calls.
- Identify ASN and network ownership for security monitoring or abuse detection.
- Resolve city-level location for user analytics or localization features in high-throughput services.
- Generate test data using the random IP address generation functions for unit or integration tests.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
GeoIP2Fast performs fast geolocation lookups for IPv4 and IPv6 addresses, returning country codes, city names, ASN information, and CIDR blocks from a local binary data file.
Yes, with conditions. Install if you need fast, offline IP geolocation and are willing to manage data file downloads separately. The library is actively maintained, has no dependencies, and supports current Python versions. High install friction (separate data file requirement) and the need to choose between country/city and IPv4/IPv6 variants make it less suitable for quick prototyping, but it is well-suited for production systems where speed and offline operation matter.
Install
geoip2fast on PyPI
pip
pip install geoip2fastuv
uv add geoip2fastpoetry
poetry add geoip2fastInstalling geoip2fast
Before you install
Installation friction is high because the package requires a separate binary data file (.dat.gz) to function; the pip package includes only country-level IPv4 data, and city or IPv6variants must be downloaded separately or generated manually. The library itself has no runtime dependencies and is actively maintained.
License in practice
MIT license is permissive; you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install geoip2fast
from geoip2fast import GeoIP2Fast
geo = GeoIP2Fast()
result = geo.lookup('8.8.8.8')
print(result)
A .dat.gz data file must be present in the library directory or application directory; the default geoip2fast.dat.gz (country IPv4 only) is included, but city or IPv6 databases require separate download.
Verify before relying
- Whether the lookup speed claim of 'less than 0.00003 seconds' is measured under realistic application conditions or in controlled benchmarks.
- Compatibility and performance behavior under PyPy3 compared to CPython across different data file sizes.
- Whether the reduced versions (geoip2fastmin.py, geoip2fastminified.py) are production-ready or still in testing.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | actively maintained — 784 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 214,693/month — #9,410 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: geoip2fast-1.2.2.tar.gz
Keywords: geoip, geoip2, geolite2, maxmind, geoip2fast, geolocation, geolocalization, geo ip, ipaddress, ip, geo, ipv4, ipv6, pure-python, purepython, pure python, geoiptofast, geoiptoofast, geoip2dat, mmdb, tools
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
IP2LocationLooks up geolocation data (country, region,…
permissive · top 15,000 on PyPI
maxminddb-geolite2Provides geolocation lookups by IP address…
unclear · top 15,000 on PyPI
pyasnpyasn performs fast offline IP address to…
permissive · top 15,000 on PyPI
geoip2-toolsAutomates downloading and updating of MaxMind…
permissive · top 15,000 on PyPI
ipinfoQueries the IPinfo.io API to retrieve…
permissive · top 15,000 on PyPI
maxminddbReads MaxMind DB files to look up geolocation…
permissive · top 5,000 on PyPI
geoip2Queries MaxMind's GeoIP web services and…
permissive · top 5,000 on PyPI
ip3countryLooks up the ISO 3166-1 alpha-2 country code…
permissive · top 5,000 on PyPI
ipwhoisRetrieves and parses whois and RDAP data for…
permissive · top 15,000 on PyPI
cidr-trieStores and queries CIDR IP address blocks (IPv4…
permissive · top 15,000 on PyPI