PyTrie
A pure Python implementation of the trie data structure.
What it is and what it does
PyTrie is a pure Python 3 implementation of the trie (prefix tree) data structure. It stores mappings where keys are sequences—typically strings—and allows you to retrieve items by exact key match or by prefix. Beyond standard dictionary operations, it supports prefix-based lookups: finding all items whose keys start with a given prefix, or finding items whose keys are prefixes of a given string.
The package has no external dependencies and installs cleanly. However, it has been abandoned since late 2020, with no commits or releases in years. If you need a trie for a small project or learning, it works; for production systems requiring ongoing maintenance or bug fixes, you should evaluate actively maintained alternatives.
Use it for:
- Autocomplete and search suggestions where you need to find all entries matching a typed prefix.
- IP routing tables or hierarchical key lookups where prefix matching is essential.
- Dictionary or spell-checker implementations that benefit from prefix-based traversal.
- Storing and querying hierarchical data like file paths or domain names by prefix.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyTrie provides a pure Python 3 trie data structure for storing and retrieving string-keyed mappings with prefix-matching capabilities.
Yes, if you need a simple, dependency-free trie for a non-critical project or learning. No, if you require active maintenance, bug fixes, or production-grade reliability—the package is abandoned and has not been updated since 2020. The permissive BSD license removes legal friction, but the lack of maintenance is the real blocker.
Install
pytrie on PyPI
pip
pip install pytrieuv
uv add pytriepoetry
poetry add pytrieInstalling PyTrie
Before you install
Installation is frictionless with no runtime dependencies. However, the package is abandoned—last commit was 2020-12-26 and no release in several years—so expect no maintenance or bug fixes going forward.
License in practice
Licensed under BSD (permissive), so you can use it freely in commercial and open-source projects without copyleft obligations.
Quickstart
pip install pytrie
from pytrie import StringTrie
trie = StringTrie()
trie['hello'] = 1
trie['help'] = 2
print(trie.keys(prefix='hel')) # Find all keys with prefix 'hel'
Verify before relying
- Whether the trie implementation handles edge cases like zero-length keys reliably in production use.
- Performance characteristics (insertion, lookup, prefix-search time complexity) relative to alternatives.
- Compatibility with modern Python versions beyond what the classifier 'Programming Language :: Python :: 3' indicates.
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 2,123 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 73,580/month — #14,973 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: PyTrie-0.4.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
pygtriepygtrie provides pure Python implementations of…
permissive · top 5,000 on PyPI
trieImplements the Ethereum Merkle Trie data…
permissive · top 15,000 on PyPI
marisa-trieProvides memory-efficient trie data structures…
copyleft · top 5,000 on PyPI
cidr-trieStores and queries CIDR IP address blocks (IPv4…
permissive · top 15,000 on PyPI
sqltrieSQLTrie implements a prefix tree (trie) data…
permissive · top 5,000 on PyPI
py-radixImplements a radix tree data structure for…
permissive · top 15,000 on PyPI
retrieBuilds efficient Trie-based regex patterns for…
permissive · top 15,000 on PyPI
immutablesProvides an immutable mapping type backed by a…
permissive · top 5,000 on PyPI
curiesConverts between URIs and compact URIs (CURIEs)…
permissive · top 15,000 on PyPI