{"library":"pytricia","title":"PyTricia","description":"PyTricia is an efficient IP address storage and lookup module for Python, based on the Patricia trie data structure. It supports IPv4 and IPv6, longest-prefix matching, and set operations. Current version 1.3.0 is stable with no known breaking changes. Release cadence is low (last release 2025).","language":"python","status":"active","last_verified":"Mon Apr 27","install":{"commands":["pip install pytricia","pip install pytricia==1.3.0"],"cli":null},"imports":["import pytricia"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pytricia\n\n# Initialize a new trie\npt = pytricia.PyTricia()\n\n# Insert a prefix\npt[\"10.0.0.0/8\"] = \"internal\"\npt[\"10.1.0.0/16\"] = \"subnet\"\n\n# Lookup an IP\nresult = pt[\"10.1.0.5\"]\nprint(result)  # prints 'subnet'\n\n# Longest prefix match\nimport ipaddress\nnet = pt.get_key(\"10.1.0.5\")\nprint(net)  # prints '10.1.0.0/16'\n\n# Check containment\nprint(\"10.0.0.0/8\" in pt)  # True\n\n# Iterate over prefixes\nfor prefix in pt:\n    print(prefix, pt[prefix])\n\n# Delete a prefix\ndel pt[\"10.1.0.0/16\"]","lang":"python","description":"Basic usage: insert, lookup, longest-prefix match, containment check, iteration, and deletion.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}