skillfed

PyTrie

A pure Python implementation of the trie data structure.

pytrie v0.4.0 73.6K downloads/30d#14,973 on PyPI24
Permissive license Abandoned released

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 pytrie

uv

uv add pytrie

poetry

poetry add pytrie

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Topic :: Software Development :: Libraries :: Python Modules

Tags

trie data structureprefix tree implementationstring prefix matchingordered tree mappingsequence key storageprefix search algorithmtrie dictionary
data-structuresprefix-search

More Python Modules packages