edlib
Lightweight, super fast library for sequence alignment using edit (Levenshtein) distance.
What it is and what it does
Edlib is a Python wrapper around a C/C++ library that computes edit distance and sequence alignment using Myers's bit-vector algorithm. It takes two sequences (strings, bytes, or iterables of hashable objects) and returns the edit distance, alignment locations, and optionally the alignment path in CIGAR format. The package supports three alignment modes: global (NW), prefix (SHW), and infix (HW), each suited to different use cases. You can also define custom character equalities to handle case-insensitive matching, wildcards, or degenerate nucleotides.
Common use cases include aligning DNA sequences in bioinformatics, calculating text or word similarity, and finding optimal subsequence matches. The library is designed for speed and can handle both small and large sequences efficiently. It has no runtime dependencies and is available as pre-built wheels for modern Python versions on standard platforms.
Use it for:
- Align DNA or protein sequences in bioinformatics pipelines to find mutations or similarities.
- Calculate edit distance between user-provided strings to detect typos or find similar text.
- Find the best alignment location of a query sequence within a larger target sequence using infix mode.
- Implement fuzzy string matching with custom equality rules (e.g., case-insensitive or with wildcards).
- Benchmark or validate sequence alignment algorithms in research or testing workflows.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Edlib calculates edit distance (Levenshtein distance) between two sequences and optionally finds the optimal alignment path, supporting global, prefix, and infix alignment modes.
Yes, if you need fast edit distance or sequence alignment. The package is lightweight, has no runtime dependencies, and offers good performance via compiled bindings. The aging maintenance status (last release 709 days ago) is a minor concern but not a blocker; the repository is still active and there are no known vulnerabilities. The constraint that alphabet length must be ≤ 256 may limit use cases with very large character sets.
Install
edlib on PyPI
pip
pip install edlibuv
uv add edlibpoetry
poetry add edlibInstalling edlib
Before you install
Medium install friction due to compiled C/C++ bindings, but pre-built wheels are available for common Python versions (3.10–3.13) and platforms (macOS, Linux, musl). Last release was 709 days ago; repository is active but aging.
License in practice
MIT license is permissive; you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install edlib
import edlib
result = edlib.align("elephant", "telephone")
print(result) # {'editDistance': 3, 'alphabetLength': 8, 'locations': [(None, 8)], 'cigar': None}
# For alignment path visualization:
result = edlib.align("elephant", "telephone", task="path")
nice = edlib.getNiceAlignment(result, "elephant", "telephone")
print("\n".join(nice.values()))
Alphabet length (unique characters across both sequences) must be <= 256.
Verify before relying
- Whether the package supports Python versions earlier than 3.10 or later than 3.13.
- Performance characteristics on sequences larger than the benchmark examples shown in the description.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | aging — 709 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 273,649/month — #8,199 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: edlib-1.3.9.post1-cp310-cp310-macosx_10_9_universal2.whl; edlib-1.3.9.post1-cp310-cp310-macosx_10_9_x86_64.whl; edlib-1.3.9.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; edlib-1.3.9.post1-cp310-cp310-musllinux_1_2_i686.whl; edlib-1.3.9.post1-cp310-cp310-musllinux_1_2_x86_64.whl; edlib-1.3.9.post1-cp311-cp311-macosx_10_9_universal2.whl; edlib-1.3.9.post1-cp311-cp311-macosx_10_9_x86_64.whl; edlib-1.3.9.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; edlib-1.3.9.post1-cp311-cp311-musllinux_1_2_i686.whl; edlib-1.3.9.post1-cp311-cp311-musllinux_1_2_x86_64.whl; edlib-1.3.9.post1-cp312-cp312-macosx_10_9_universal2.whl; edlib-1.3.9.post1-cp312-cp312-macosx_10_9_x86_64.whl; edlib-1.3.9.post1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; edlib-1.3.9.post1-cp312-cp312-musllinux_1_2_i686.whl; edlib-1.3.9.post1-cp312-cp312-musllinux_1_2_x86_64.whl; edlib-1.3.9.post1-cp313-cp313-macosx_10_13_universal2.whl; edlib-1.3.9.post1-cp313-cp313-macosx_10_13_x86_64.whl; edlib-1.3.9.post1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; edlib-1.3.9.post1-cp313-cp313-musllinux_1_2_i686.whl; edlib-1.3.9.post1-cp313-cp313-musllinux_1_2_x86_64.whl
Keywords: edit, distance, levenshtein, align, sequence, bioinformatics
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
editdistanceComputes the edit distance (Levenshtein…
permissive · top 5,000 on PyPI
polylevenPolyleven computes Levenshtein distance between…
unclear · top 5,000 on PyPI
python-LevenshteinComputes Levenshtein edit distance, string…
copyleft · top 5,000 on PyPI
editdistpyComputes Levenshtein and Damerau-Levenshtein…
permissive · top 15,000 on PyPI
kaldialignComputes edit distance, alignment, and word…
permissive · top 15,000 on PyPI
aptedComputes the tree edit distance between two…
permissive · top 15,000 on PyPI
LevenshteinLevenshtein computes string edit distances,…
copyleft · top 1,000 on PyPI
textdistanceComputes distance and similarity between text…
permissive · top 5,000 on PyPI
strsimpyImplements a dozen string similarity and…
permissive · top 15,000 on PyPI
fastdtwfastdtw computes approximate Dynamic Time…
permissive · top 15,000 on PyPI