pygtrie
A pure Python trie data structure implementation.
Decision gist · record as of 2026-08-14
Yes, if you need trie-based prefix lookups and can tolerate dormant maintenance. The package is stable, has no dependencies, and solves a specific problem well. However, verify that the empty requires_python field doesn't mask compatibility issues with your Python version, and be aware that bug fixes or updates are unlikely without community contribution.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Installation is straightforward with no runtime dependencies.
- The package is marked Production/Stable but dormant—last release was 2022-07-16 and the repository received its last commit 2024-03-26, so expect no active maintenance or rapid bug fixes.
License · maintenance · safety
Apache-2.0 (permissive) — Licensed under Apache-2.0 (permissive), so you can use, modify, and distribute pygtrie freely in commercial and private projects with minimal restrictions.
last release 2022-07-16 (1490 days) · last repo commit 2024-03-26 · 42 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 13,875,383 downloads/mo, #1,261 on PyPI
Alternatives
Verify before relying
pip install pygtrie
from pygtrie import StringTrie
trie = StringTrie({'foo/bar': 42}, separator='/')
print(trie['foo/bar']) # 42
print(list(trie.prefixes('foo/bar/baz'))) # prefix lookup- Whether the package is actively maintained or receives security updates despite dormant status
- Performance characteristics and memory usage compared to alternative trie implementations
- Compatibility with Python versions beyond 2.7 and 3.x (requires_python field is empty)
What it is and what it does
pygtrie is a pure Python trie (prefix tree) library that stores key-value pairs organized by shared prefixes, allowing efficient prefix-based lookups and iteration. It provides three main classes—Trie, CharTrie, and StringTrie—each implementing Python's mutable mapping interface (dict-like behavior), plus a PrefixSet class for storing sets of prefixes where membership includes all keys sharing a stored prefix.
The library is useful when you need to query or iterate over all keys with a common prefix, find shortest or longest prefix matches, or delete entire subtrees of keys at once. It works as a drop-in dict replacement in most cases but shines when prefix operations are central to your use case. The package has no runtime dependencies and is compatible with Python 2.x and 3.x, though it is currently dormant—last release was 2022-07-16.
Use it for
- Autocomplete and search-as-you-type systems that need to retrieve all keys starting with a user's input prefix
- IP routing tables or CIDR block lookups where you need longest-prefix matching
- Dictionary or spell-checker implementations that support prefix-based word lookups and suggestions
- File path or URL hierarchies where you need to query or delete all entries under a given path prefix
- Storing and querying hierarchical configuration keys or namespaced settings by prefix
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need trie-based prefix lookups and can tolerate dormant maintenance.
The package is stable, has no dependencies, and solves a specific problem well. However, verify that the empty requires_python field doesn't mask compatibility issues with your Python version, and be aware that bug fixes or updates are unlikely without community contribution.
Install
pygtrie on PyPI
Before you install
Installation is straightforward with no runtime dependencies. The package is marked Production/Stable but dormant—last release was 2022-07-16 and the repository received its last commit 2024-03-26, so expect no active maintenance or rapid bug fixes.
License in practice
Licensed under Apache-2.0 (permissive), so you can use, modify, and distribute pygtrie freely in commercial and private projects with minimal restrictions.
Quickstart
pip install pygtrie
from pygtrie import StringTrie
trie = StringTrie({'foo/bar': 42}, separator='/')
print(trie['foo/bar']) # 42
print(list(trie.prefixes('foo/bar/baz'))) # prefix lookup
Verify before relying
- Whether the package is actively maintained or receives security updates despite dormant status
- Performance characteristics and memory usage compared to alternative trie implementations
- Compatibility with Python versions beyond 2.7 and 3.x (requires_python field is empty)
Package facts
| License | Apache-2.0 permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Dormant 1,490 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 13,875,383 / month, #1,261 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Topic :: Software Development :: Libraries :: Python Modules |
Evidence: pygtrie-2.5.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “prefix lookup dictionary”
- pygtriepygtrie provides pure Python implementations of trie (prefix tree)…
- py-radixImplements a radix tree data structure for efficient storage and…
- DAWG2-PythonRead-only access to DAWG (directed acyclic word graph) files created…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also marisa-trie · PyTrie · sqltrie · trie · py-radix · cidr-trie · retrie · treelib · immutables · multi_key_dict