polyleven
A fast C-implemented library for Levenshtein distance
What it is and what it does
Polyleven is a C-implemented library that calculates the Levenshtein distance (edit distance) between two strings. It measures how many single-character edits—insertions, deletions, or substitutions—are needed to transform one string into another. The library is designed to be fast across both short inputs like English words and long inputs like DNA sequences, with no external dependencies beyond Python itself.
You use it by importing the `levenshtein()` function and passing two strings; it returns the distance as an integer. Optionally, you can provide a threshold as a third argument to stop early if the distance exceeds that limit, which can speed up comparisons when you only care whether strings are similar within a certain tolerance.
Use it for:
- Spell-checking and autocorrect: find candidate words within a fixed edit distance of a misspelled input.
- Duplicate detection: identify similar records in datasets by comparing strings with a distance threshold.
- DNA/protein sequence analysis: compute alignment distances for biological sequences.
- Fuzzy string matching in search: rank results by similarity to a query term.
- Data deduplication: flag records that are nearly identical but not exact matches.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Polyleven computes Levenshtein distance between two strings using a fast C implementation, with optional threshold support to skip expensive comparisons.
Yes, if you need fast Levenshtein distance computation. The library is mature (Production/Stable), has no dependencies, supports current Python versions, and shows strong performance. Caveat: verify the license metadata before use in proprietary projects, as the license treatment is marked unclear despite the description claiming MIT.
Install
polyleven on PyPI
pip
pip install polylevenuv
uv add polylevenpoetry
poetry add polylevenInstalling polyleven
Before you install
Medium install friction due to compiled wheels, but pre-built binaries are available for common platforms (Python 3.10–3.12 on macOS, Linux, Windows, and ARM). Last release was 186 days ago; repo is active and not archived.
License in practice
License treatment is unclear in the metadata, though the description states MIT License. Verify the actual license terms before use in proprietary projects.
Quickstart
pip install polyleven
from polyleven import levenshtein
print(levenshtein('aaa', 'ccc')) # Output: 3
print(levenshtein('acc', 'ccc', 1)) # With threshold: 1
Requires Python 3.8 or later; compiled wheels available for most platforms but source build may require a C compiler.
Verify before relying
- License metadata is marked unclear despite description stating MIT—confirm actual license terms before use.
- Performance claims in description (e.g., 2303420 pairs/sec) are from benchmarks on Python 3.5.3; current performance on modern Python versions unknown.
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | aging — 186 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,665,512/month — #2,261 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: polyleven-0.11.0-cp310-cp310-macosx_10_9_x86_64.whl; polyleven-0.11.0-cp310-cp310-macosx_11_0_arm64.whl; polyleven-0.11.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; polyleven-0.11.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; polyleven-0.11.0-cp310-cp310-musllinux_1_2_aarch64.whl; polyleven-0.11.0-cp310-cp310-musllinux_1_2_x86_64.whl; polyleven-0.11.0-cp310-cp310-win32.whl; polyleven-0.11.0-cp310-cp310-win_amd64.whl; polyleven-0.11.0-cp310-cp310-win_arm64.whl; polyleven-0.11.0-cp311-cp311-macosx_10_9_x86_64.whl; polyleven-0.11.0-cp311-cp311-macosx_11_0_arm64.whl; polyleven-0.11.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; polyleven-0.11.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; polyleven-0.11.0-cp311-cp311-musllinux_1_2_aarch64.whl; polyleven-0.11.0-cp311-cp311-musllinux_1_2_x86_64.whl; polyleven-0.11.0-cp311-cp311-win32.whl; polyleven-0.11.0-cp311-cp311-win_amd64.whl; polyleven-0.11.0-cp311-cp311-win_arm64.whl; polyleven-0.11.0-cp312-cp312-macosx_10_13_x86_64.whl; polyleven-0.11.0-cp312-cp312-macosx_11_0_arm64.whl
Keywords: Levenshtein, distance
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
python-LevenshteinComputes Levenshtein edit distance, string…
copyleft · top 5,000 on PyPI
editdistanceComputes the edit distance (Levenshtein…
permissive · top 5,000 on PyPI
edlibEdlib calculates edit distance (Levenshtein…
permissive · top 15,000 on PyPI
LevenshteinLevenshtein computes string edit distances,…
copyleft · top 1,000 on PyPI
editdistpyComputes Levenshtein and Damerau-Levenshtein…
permissive · top 15,000 on PyPI
DistanceComputes distance metrics (Levenshtein,…
copyleft · top 15,000 on PyPI
textdistanceComputes distance and similarity between text…
permissive · top 5,000 on PyPI
stringzillaStringZilla provides SIMD and SWAR-accelerated…
permissive · top 5,000 on PyPI
strsimpyImplements a dozen string similarity and…
permissive · top 15,000 on PyPI
pylcsComputes longest common subsequence, longest…
permissive · top 15,000 on PyPI