poptrie
| staging | cron | production |
|---|---|---|
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.5.2
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 | Actions Reset |
|---|---|---|---|---|
| poptrie-0.5.2-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for poptrie-0.5.2-cp310-abi3-win_amd64.whl |
| poptrie-0.5.2-cp310-abi3-manylinux_2_34_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.34+ x86-64 | Details for poptrie-0.5.2-cp310-abi3-manylinux_2_34_x86_64.whl |
| poptrie-0.5.2-cp310-abi3-macosx_11_0_universal2.whl | CPython 3.10 | abi3 | macOS 11.0+ universal2 (ARM64, x86-64) | Details for poptrie-0.5.2-cp310-abi3-macosx_11_0_universal2.whl |
Total release size: 632.8 kB
Release files / poptrie-0.5.2-cp310-abi3-win_amd64.whl
| Download URL | poptrie-0.5.2-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 159.8 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
d45d833cd85cac8c594358ac0d29cc758e92f87778197f56ee227b7debd0bf2a
|
|
BLAKE2b-256 checksum How to use checksums |
ec80ed493f6832bdf6537ae680dafa9dd1e27ee6ef08f733de92f62d7cc6ae61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / poptrie-0.5.2-cp310-abi3-manylinux_2_34_x86_64.whl
| Download URL | poptrie-0.5.2-cp310-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 256.1 kB |
| Tags | CPython 3.10 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b2cc3991bbb90ca5e6110410bcc22d8ac28c50894589a870e93da19a13ff612a
|
|
BLAKE2b-256 checksum How to use checksums |
4e9a4eb33024284aa8c07ae408bd50db93e4595af8fa5fb0a4ab12da1f59459c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / poptrie-0.5.2-cp310-abi3-macosx_11_0_universal2.whl
| Download URL | poptrie-0.5.2-cp310-abi3-macosx_11_0_universal2.whl |
|---|---|
| Size | 216.9 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
574e347b6b7f821bba0e98b671883177a37c62dfb6f088d454e7eea929877cbf
|
|
BLAKE2b-256 checksum How to use checksums |
5bd2d09cfb3762a56535e2a84f00d09d1e90a12ed3aea93d5fa1f675c06c2d5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for poptrie 0.5.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.