A pure Python implementation of the trie (prefix tree) data structure, version 0.4.0. No longer actively maintained; last release 2013.
pip install pytrieNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create a trie, insert key-value pairs, and query with prefix.
Use StringTrie for string keys to ensure correct prefix semantics.
Pin Python version <3.12 or switch to actively maintained alternatives like 'datrie' or 'pygtrie'.
Install sortedcontainers: pip install sortedcontainers; or call sorted(t).
Use Python <3.12, or monkey-patch: import collections; collections.Iterable = collections.abc.Iterable before importing pytrie.
Use keys(prefix) and filter longest, or switch to pygtrie which has longest_prefix().
Use StringTrie for string keys; ensure all key parts are hashable.