ahocorasick-rs
Search for multiple substrings at the same time, and quickly too
Decision gist · record as of 2026-08-14
Yes, if you need to search for multiple patterns in text or bytes. The Aho-Corasick algorithm is significantly faster than sequential pattern matching. Install friction is moderate (compiled wheels) but well-supported across platforms. No vulnerabilities reported, actively maintained, and permissive license. Not necessary if you only search for single patterns or have very few patterns where overhead isn't a concern.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Medium install friction due to compiled wheels; prebuilt binaries available for Python 3.10 through modern versions on macOS, Linux, and Windows.
- Actively maintained with recent commits and no reported vulnerabilities.
License · maintenance · safety
Apache 2.0 (permissive) — Licensed under Apache 2.0 (permissive), allowing use in commercial and proprietary projects with minimal restrictions.
last release 2025-10-08 (310 days) · last repo commit 2026-08-10 · 233 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 534,741 downloads/mo, #6,131 on PyPI
Alternatives
Verify before relying
pip install ahocorasick-rs
import ahocorasick_rs
patterns = ["hello", "world"]
ac = ahocorasick_rs.AhoCorasick(patterns)
matches = ac.find_matches_as_strings("hello world")
# Returns: ['hello', 'world']- Performance comparison with pyahocorasick under realistic workloads and pattern counts.
- Memory overhead of different Implementation choices for typical use cases.
- Thread safety guarantees beyond the documented mutable-buffer constraint.
What it is and what it does
ahocorasick_rs is a Python wrapper around the Rust aho-corasick library that finds all occurrences of multiple patterns in a single pass through a text or byte string. It implements the Aho-Corasick automaton algorithm, which is significantly faster than searching for patterns sequentially, especially when you have many patterns or large haystacks. The package supports both string and bytes searching, with configurable matching strategies (Standard, LeftmostFirst, LeftmostLongest) and optional overlapping match detection.
The library exposes two main classes: AhoCorasick for string patterns and BytesAhoCorasick for byte patterns. You can tune performance by choosing between different underlying automaton implementations (NoncontiguousNFA, ContiguousNFA, DFA) and control memory usage through pattern caching. It has one runtime dependency (typing-extensions) and requires Python 3.10 or later.
Use it for
- Scanning log files or documents for multiple keywords or error codes in a single pass.
- Filtering or redacting sensitive terms from text or data streams.
- Building search indices or content-matching systems that need to detect many patterns efficiently.
- Detecting multiple signatures or indicators in binary or text data.
- Tokenizing or lexing source code by matching multiple reserved words and operators simultaneously.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to search for multiple patterns in text or bytes.
The Aho-Corasick algorithm is significantly faster than sequential pattern matching. Install friction is moderate (compiled wheels) but well-supported across platforms. No vulnerabilities reported, actively maintained, and permissive license. Not necessary if you only search for single patterns or have very few patterns where overhead isn't a concern.
Install
ahocorasick-rs on PyPI
Before you install
Medium install friction due to compiled wheels; prebuilt binaries available for Python 3.10 through modern versions on macOS, Linux, and Windows. Actively maintained with recent commits and no reported vulnerabilities.
Requires Python 3.10 or later.
License in practice
Licensed under Apache 2.0 (permissive), allowing use in commercial and proprietary projects with minimal restrictions.
Quickstart
pip install ahocorasick-rs
import ahocorasick_rs
patterns = ["hello", "world"]
ac = ahocorasick_rs.AhoCorasick(patterns)
matches = ac.find_matches_as_strings("hello world")
# Returns: ['hello', 'world']
Verify before relying
- Performance comparison with pyahocorasick under realistic workloads and pattern counts.
- Memory overhead of different Implementation choices for typical use cases.
- Thread safety guarantees beyond the documented mutable-buffer constraint.
Package facts
| License | Apache 2.0 permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | 1 packagetyping-extensions |
| Maintenance | Actively maintained 310 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 534,741 / month, #6,131 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
Evidence: ahocorasick_rs-1.0.3-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl; ahocorasick_rs-1.0.3-cp310-cp310-macosx_10_12_x86_64.whl; ahocorasick_rs-1.0.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; ahocorasick_rs-1.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; ahocorasick_rs-1.0.3-cp310-cp310-win_amd64.whl; ahocorasick_rs-1.0.3-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl; ahocorasick_rs-1.0.3-cp311-cp311-macosx_10_12_x86_64.whl; ahocorasick_rs-1.0.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; ahocorasick_rs-1.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; ahocorasick_rs-1.0.3-cp311-cp311-win_amd64.whl; ahocorasick_rs-1.0.3-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl; ahocorasick_rs-1.0.3-cp312-cp312-macosx_10_12_x86_64.whl; ahocorasick_rs-1.0.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; ahocorasick_rs-1.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; ahocorasick_rs-1.0.3-cp312-cp312-win_amd64.whl; ahocorasick_rs-1.0.3-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl; ahocorasick_rs-1.0.3-cp313-cp313-macosx_10_12_x86_64.whl; ahocorasick_rs-1.0.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; ahocorasick_rs-1.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; ahocorasick_rs-1.0.3-cp313-cp313-win_amd64.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 › “pattern matching in text”
- ahocorasick-rsSearches for multiple substrings in text or bytes using the…
- pyahocorasickFinds multiple keyword strings in text efficiently using an…
- onigurumacffiProvides Python bindings to the Oniguruma regex engine via CFFI,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Text Processing packages
A drop-in replacement for Python's standard `re` module that adds advanced regex features like nested sets, fuzzy matching, lookaround in conditionals, and full Unicode case-folding while maintaining backward compatibility.
pyparsing provides a library for building text parsers directly in Python code using composable grammar classes, handling quoted strings, whitespace variation, and embedded comments without regex or lex/yacc.
Install it if you need to parse text or define grammars programmatically.
fonttools manipulates font files in multiple formats (TrueType, OpenType, AFM, Type 1, Mac-specific) and includes TTX, a tool to convert fonts to and from XML text format.
Install it if you need to read, write, or manipulate fonts programmatically or via the TTX command-line tool.
Docutils converts plaintext documentation in reStructuredText format into multiple output formats including HTML, XML, and LaTeX using a modular processing system.
RapidFuzz provides fast fuzzy string matching using Levenshtein Distance and related metrics, implemented mostly in C++ with Python bindings for rapid similarity scoring and approximate string matching.
Install it if you need fuzzy string matching; it's a solid replacement for FuzzyWuzzy with better licensing and performance.
tinycss2 parses CSS strings into token and block objects, and generates CSS strings from those objects, following the CSS Syntax Level 3 specification without enforcing specific properties or values.
Install it if your project requires CSS tokenization or syntax manipulation.
See also ahocorapy · pyahocorasick · multiregex · rebulk · flashtext · fuzzyfinder · wcmatch · strsimpy · farm-haystack · django-haystack