--- id: py-radix version: "1.1.0" license: BSD license_treatment: permissive maintenance: aging --- # py-radix — Radix tree implementation License: permissive · Maintenance: aging · Downloads: 211.8K/mo ## What it is and what it does py-radix provides a radix tree (also called a trie) optimized for storing and retrieving network prefixes. It accepts IPv4 and IPv6 addresses in multiple formats—CIDR notation, separate network and mask length, or binary packed addresses—and supports three types of prefix searches: exact match, best match (longest prefix, used in routing), and worst match (shortest prefix). The tree stores arbitrary metadata in a data dictionary attached to each node. The package is implemented primarily in C for speed, with a pure Python fallback available. It has no runtime dependencies and compiles to wheels for Python 3.9–3.12 on macOS, Linux, Windows, and ARM architectures. The API is straightforward: create a tree, add prefixes, and query them using one of the search methods. It is commonly used in network applications, routing simulators, and IP-based access control systems. Use it for: - Build a routing table simulator or network lookup service that matches IP addresses to their containing network prefixes. - Implement IP-based access control or firewall rules by storing allowed/blocked CIDR ranges and checking incoming addresses. - Store geolocation or ASN data indexed by IP prefix and retrieve it with a single lookup. - Analyze network traffic by classifying packets into predefined subnets and aggregating statistics per prefix. - Validate or normalize network configurations by checking whether proposed prefixes overlap with existing allocations. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Implements a radix tree data structure for efficient storage and lookup of IPv4 and IPv6 network prefixes, commonly used for routing table operations. Yes, if you need efficient prefix matching for IPv4 or IPv6 networks. The package is stable, permissively licensed, has no dependencies, and compiles to wheels for most platforms. The aging maintenance status (last release 253 days ago) is acceptable for a mature, narrow-purpose library with no known vulnerabilities, but check whether the feature set meets your exact needs before committing to it as a long-term dependency. ## Install pip install py-radix uv add py-radix poetry add py-radix ## Installing py-radix Before you install: Medium install friction due to C extension compilation; wheels are pre-built for Python 3.9–3.12 across multiple platforms (macOS, Linux, Windows, ARM), reducing friction for standard environments. Maintenance status is aging—last release 253 days ago, but the repository remains active and not archived. License in practice: Licensed under BSD (permissive), allowing use in both open-source and proprietary projects with minimal restrictions. The underlying C implementation is subject to a 4-term BSD license; see LICENSE file for details. Quickstart: import radix rtree = radix.Radix() rnode = rtree.add("10.0.0.0/8") rnode.data["label"] = "my_data" # Best-match search (routing-style lookup) result = rtree.search_best("10.123.45.6") if result: print(result.prefix) C extension requires a C compiler at build time unless RADIX_NO_EXT=1 is set; pre-built wheels available for Python 3.9–3.12 on common platforms reduce this friction. Verify before relying: - Whether the pure Python fallback (when C extension is disabled) has performance implications for large trees. - Performance characteristics or benchmarks for trees with thousands or millions of prefixes. - Whether IPv6 and IPv4 prefixes can be mixed in the same tree without performance degradation. ## Package facts - License: BSD (permissive) - Python support: unspecified - Install friction: medium - Maintenance: aging - Downloads: 211.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags radix tree implementation, IP prefix lookup, routing table data structure, IPv4 IPv6 network storage, CIDR prefix matching, network prefix search, trie tree networking, routing, ip-networks, data-structures [View on SkillFed](https://skillfed.io/packages/py-radix) · [View on PyPI](https://pypi.org/project/py-radix/)