retrie
Efficient Trie-based regex unions for blacklist/whitelist filtering and one-pass mapping-based string replacing
Decision gist · record as of 2026-08-14
Yes. Retrie is a focused, well-maintained tool that solves a real performance problem for bulk string matching and replacement. Its low install friction, permissive MIT license, and broad Python version support make it a safe dependency. Use it when you need to filter or replace large word sets and regex performance matters; skip it if you only have a handful of patterns to match.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python, no compiled dependencies, and actively maintained with a recent commit on 2026-08-01.
- Supports Python 2.7 through 3.12, though reliance on the unmaintained cached-property backport for older Python versions may warrant attention in long-term projects.
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions—include a copy of the license and you are free to modify and distribute.
last release 2024-02-22 (904 days) · last repo commit 2026-08-01 · 76 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 101,490 downloads/mo, #12,931 on PyPI
Alternatives
Verify before relying
pip install retrie
from retrie.retrie import Blacklist
blacklist = Blacklist(["abc", "foo"], match_substrings=False)
blacklist.cleanse_text("good abc foobar")- Whether the Trie structure provides measurable performance gains for specific word-set sizes or text lengths.
- How the package handles Unicode edge cases or non-ASCII character matching in practice.
What it is and what it does
Retrie solves the performance problem of matching or replacing large sets of strings using naive regex unions. Instead of compiling a pattern like `(?:abc|abs|foo)` which becomes slow as the word list grows, it builds a Trie data structure that produces a more efficient pattern like `(?:ab[cs]|foo)`. The package provides three main classes—Trie (the underlying structure), Blacklist (filter out unwanted strings), Whitelist (keep only allowed strings), and Replacer (perform bulk find-and-replace)—each with options to match whole words or substrings.
The implementation is pure Python with minimal dependencies (only typing and cached-property), making it portable and easy to integrate. It supports both Python 2.7 and modern Python versions, and has been actively maintained since its 2020 release. The API is straightforward: instantiate a class with a word list or mapping, optionally configure matching behavior, and call methods like `filter()`, `cleanse_text()`, or `replace()` on your input.
Use it for
- Filter spam or profanity from user-generated text by maintaining a blacklist of forbidden terms.
- Extract only whitelisted keywords or entities from documents for data cleaning pipelines.
- Perform bulk find-and-replace operations (e.g., synonym substitution, URL rewriting) in a single pass.
- Build content moderation systems that need to match many patterns efficiently without regex compilation overhead.
- Normalize or standardize text by replacing multiple variant spellings or abbreviations with canonical forms.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Retrie is a focused, well-maintained tool that solves a real performance problem for bulk string matching and replacement. Its low install friction, permissive MIT license, and broad Python version support make it a safe dependency. Use it when you need to filter or replace large word sets and regex performance matters; skip it if you only have a handful of patterns to match.
Install
retrie on PyPI
Before you install
Low friction: pure Python, no compiled dependencies, and actively maintained with a recent commit on 2026-08-01. Supports Python 2.7 through 3.12, though reliance on the unmaintained cached-property backport for older Python versions may warrant attention in long-term projects.
License in practice
MIT license permits commercial and private use with minimal restrictions—include a copy of the license and you are free to modify and distribute.
Quickstart
pip install retrie
from retrie.retrie import Blacklist
blacklist = Blacklist(["abc", "foo"], match_substrings=False)
blacklist.cleanse_text("good abc foobar")
Verify before relying
- Whether the Trie structure provides measurable performance gains for specific word-set sizes or text lengths.
- How the package handles Unicode edge cases or non-ASCII character matching in practice.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.* |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagestypingcached-property |
| Maintenance | Actively maintained 904 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 101,490 / month, #12,931 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 :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: Utilities |
Evidence: retrie-0.3.1-py2.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 › “trie regex pattern matching”
- retrieBuilds efficient Trie-based regex patterns for fast matching and…
- flashtextExtracts or replaces keywords in text using the FlashText algorithm,…
- pyahocorasickFinds multiple keyword strings in text efficiently using an…
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 multiregex · rebulk · flashtext · pyahocorasick · marisa-trie · greenery · textsearch · PyTrie · pygtrie · repath