Skip to content
KarelZePublic

About

An extremely fast Python library for the Levenshtein distance, written in Rust. 🦀

Topics

Resources

Stars

8 stars

Watchers

1 watching

Forks

Repository files navigation

lev

lev is an extremely fast Python library for the Levenshtein distance and similarity ratio, written in Rust. 🦀

Installation

uv add lev-rs

or if you prefer slow:

pip install lev-rs

Wheels are available for Python 3.10+, including free-threaded builds, on Linux, macOS, and Windows.

Usage

import lev

lev.distance("kitten", "sitting")  # 3
lev.distance("résumé", "resume")  # 2
lev.distance("日本語", "日本")  # 1

lev.ratio("kitten", "sitting")  # 0.615...
lev.ratio("abc", "xyz")  # 0.0
lev.ratio("", "")  # 1.0

See the API Reference for details.

Benchmarks

lev is compared against the fastest Levenshtein libraries for Python: rapidfuzz, polyleven, editdistance, and edlib. Each plot shows the total time for 1,000 calls (lower is better).

Plots were generated by GitHub Actions on Ubuntu 24.04 with Python 3.13. Reproduce them locally with uv run scripts/benchmark.py.

ASCII

ASCII benchmark

Latin-1

Latin-1 benchmark

CJK

CJK benchmark

Emoji

Emoji benchmark

Realistic Text

A short customer support message with a few natural typos.

Realistic text benchmark

Contact

Open an issue or email github@markusbilz.com.

About

An extremely fast Python library for the Levenshtein distance, written in Rust. 🦀

Topics

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages