Registry / http-networking / cidr-trie

cidr-trie

JSON →
library3.1.2pypypi✓ verified 85d ago

A Python library for storing and searching CIDR prefixes in a trie structure. It enables efficient longest-prefix matching of IP addresses against a set of CIDR blocks. The current version is 3.1.2. Release cadence is intermittent.

pip install cidr-trie
INSTALL
IMPORT
SIG · CIDR-TRIE
C
cidr-trie
http-networkingpythonv3.1.2
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PatriciaTrie
from cidr_trie import PatriciaTrie
from cidr_trie import CidrTrie
PatriciaNode
from cidr_trie import PatriciaNode
cidr_atoi
from cidr_trie import cidr_atoi

Create a trie, insert CIDR prefixes, and perform longest-prefix matching.

from cidr_trie import CidrTrie, IpNetwork trie = CidrTrie() trie.insert(IpNetwork('10.0.0.0/8')) trie.insert(IpNetwork('10.0.0.0/16')) result = trie['10.0.0.5'] print(result) # IpNetwork('10.0.0.0/16')
Debug
Known issues
deprecatedThe method `find_longest_prefix` is deprecated since v3.0.0; use `trie[ip]` instead.
fix
Replace `trie.find_longest_prefix(ip)` with `trie[ip]`
affects: >=3.0.0
breakingCidrTrie.no_prefix() was removed in v3.0.0. Use `trie[ip]` and catch KeyError or pre-check with `ip in trie`.
fix
Replace `trie.no_prefix(ip)` with `try: result = trie[ip]; except KeyError: # handle missing`
affects: >=3.0.0
gotchaCidrTrie is not threadsafe. Concurrent modifications may corrupt internal state.
fix
Use a threading lock when modifying the trie from multiple threads.
affects: all
Upgrade
Version history
3.1.2latest on PyPI · released Jul 5, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
cidr-trie — pip install cidr-trie · libregistry