poptrie
High-performance IP lookup backed by Rust. This public repository owns the final Python facade and publishes wheels.
Stable public contract:
from poptrie import IpSearcherIpSearcherresolves topoptrie.ip_searcher.IpSearcher- native extension details are intentionally hidden behind the facade
Installation
Install from PyPI:
pip install poptrie
Usage
import socket
from pathlib import Path
from poptrie import IpSearcher
bin_path = Path("china-ip.bin")
searcher = IpSearcher(bin_path)
print("1.0.1.1" in searcher)
print(searcher.contains_ip("1.0.1.1"))
print(searcher.lookup_country("1.0.1.1"))
print(searcher.is_china("1.0.1.1"))
ips = ["1.0.1.1", "8.8.8.8", "240e::1", "2001:db8::"]
print(searcher.contains_ips(ips))
print(searcher.lookup_countries(ips))
print(searcher.matches_countries(ips, "CN"))
v4_ips = ["1.0.1.1", "8.8.8.8", "110.16.0.1", "127.0.0.1"]
packed_v4 = b"".join(socket.inet_pton(socket.AF_INET, ip) for ip in v4_ips)
print(searcher.contains_packed(packed_v4, is_v6=False))
print(searcher.lookup_countries_packed(packed_v4, is_v6=False))
print(searcher.matches_country_packed(packed_v4, "CN", is_v6=False))
Example
python example.py
Tests
Public facade verification:
python -m unittest discover tests
Notes
- Country lookups are resolved in Rust and exposed as 2-letter strings in Python.
*_packedmethods are intended for high-throughput byte-oriented workloads.- The public Python facade lives in
poptrie/__init__.pyandpoptrie/ip_searcher.py. - Files such as
*-overlap.csvare input conflict audit reports, not evidence that the final.datfiles still contain overlapping CIDRs.
Metadata
Release files for poptrie 0.4.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| poptrie-0.4.3-cp38-abi3-win_amd64.whl | CPython 3.8 | abi3 | Windows x86-64 | Details |
| poptrie-0.4.3-cp38-abi3-manylinux_2_34_x86_64.whl | CPython 3.8 | abi3 | Linux glibc 2.34+ x86-64 | Details |
| poptrie-0.4.3-cp38-abi3-macosx_11_0_universal2.whl | CPython 3.8 | abi3 | macOS 11.0+ universal2 (ARM64, x86-64) | Details |
Total release size: 616.7 kB
Release files / poptrie-0.4.3-cp38-abi3-win_amd64.whl
| Download URL | poptrie-0.4.3-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 154.5 kB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
45c5366cf020dc191c26a2efb9e651758ac3c4c18f69c2d82a0ffa0dc7120191
|
|
BLAKE2b-256 checksum How to use checksums |
887fe9b68985e76bb4a758bf7d26f54723e5536007257911986f5c41f2095711
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / poptrie-0.4.3-cp38-abi3-manylinux_2_34_x86_64.whl
| Download URL | poptrie-0.4.3-cp38-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 251.0 kB |
| Tags | CPython 3.8 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
05b66acf6f0e84b4c45385885acd75f8b80ca89ab089a16c1b72c400a7f86bf6
|
|
BLAKE2b-256 checksum How to use checksums |
9971bdd50095be1a360ef07e7b31aafbc7d13d0d842edfa928d359fc4936c2bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / poptrie-0.4.3-cp38-abi3-macosx_11_0_universal2.whl
| Download URL | poptrie-0.4.3-cp38-abi3-macosx_11_0_universal2.whl |
|---|---|
| Size | 211.1 kB |
| Tags | CPython 3.8 abi3 macOS 11.0+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
407a1e5e05056787b41085804fb12e5a000af6cd22f2cc96bd265ee0cf7e651c
|
|
BLAKE2b-256 checksum How to use checksums |
b05f72db69005118ecf8281b0dae25cfa184401bce7d5760c6f989ea4d6959fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|