Rewrite of IPToCC with an emphesis on performance (>10000x faster queries!) and memory reduction (99% less!), with no external dependencies and database that is updated nightly. Designed to be blazing fast on even the smallest VPS cloud instances.
- No external API call
- No paid GeoIP service
- Offline
- Database updated nightly
- IPv4
- IPv6 (TODO)
Measured on M3 MacBook Air with Python 3.9.6
- Load database:
ctx = ip_to_country.Context()-> 0.0006s (vs IPToCC 19.158s) - IP to Country Code:
cc = ctx.country_code(ip)-> 0.0182ms (vs IPToCC 237.057ms) - Peak memory consumption: ~3MB (vs IPToCC 394MB)
Install the latest version with the latest database...
pip install git+https://github.com/jamesdolan/ip_to_country.git@mainimport ip_to_country
ctx = ip_to_country.Context()
cc = ctx.country_code("<IPv4/IPv6 address>")