Metadata-Version: 2.4
Name: lev-rs
Version: 0.2.1
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Dist: edlib ; extra == 'benchmark'
Requires-Dist: editdistance>=0.8.1 ; extra == 'benchmark'
Requires-Dist: matplotlib>=3.10.9 ; extra == 'benchmark'
Requires-Dist: matplotx>=0.3.10 ; extra == 'benchmark'
Requires-Dist: numpy>=2.0 ; extra == 'benchmark'
Requires-Dist: rapidfuzz>=3.14.5 ; extra == 'benchmark'
Requires-Dist: commitizen ; extra == 'dev'
Requires-Dist: maturin ; extra == 'dev'
Requires-Dist: prek ; extra == 'dev'
Requires-Dist: pytest-codspeed ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: ruff ; extra == 'dev'
Requires-Dist: zensical ; extra == 'docs'
Requires-Dist: mkdocstrings[python] ; extra == 'docs'
Provides-Extra: benchmark
Provides-Extra: dev
Provides-Extra: docs
License-File: LICENSE
Summary: A extremely fast Python library for the Levenshtein distance, written in Rust 🦀.
Keywords: distance,levenshtein,strings
Author-email: Markus Bilz <github@markusbilz.com>
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Bug Tracker, https://github.com/KarelZe/lev/issues
Project-URL: Homepage, https://github.com/KarelZe/lev

# lev

`lev` is an extremely fast Python library for the [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) and similarity ratio. Written in Rust. 🦀

## Installation

```bash
uv add lev-rs
```

or if you prefer slow:

```bash
pip install lev-rs
```

## Usage

```python
import lev

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

lev.ratio("kitten", "sitting")      # 0.769...
lev.ratio("", "")                   # 1.0
```

For more details on the API see the [API Reference](https://karelze.github.io/lev/api/).

## Benchmarks

`lev` is benchmarked against the fastest Python Levenshtein libraries:
[rapidfuzz](https://github.com/rapidfuzz/RapidFuzz),
[editdistance](https://github.com/roy-ht/editdistance), and
[edlib](https://github.com/Martinsos/edlib). We excluded slower implementations like
[pylev](https://github.com/toastdriven/pylev/tree/main) and [python-Levenshtein](https://github.com/ztane/python-Levenshtein).

> Benchmarks were run on an Apple Mac Mini M2 Pro (macOS 26.2) using Python 3.13. Each string pair is exactly 100 characters long. Results represent the total wall time for 1,000 repetitions using Python's `timeit`. To reproduce, run [`scripts/benchmark.py`](https://github.com/KarelZe/lev/blob/main/scripts/benchmark.py).

### ASCII

`lev` is significantly faster than the other libraries on 100-character ASCII strings.

![ASCII benchmark – dark](https://raw.githubusercontent.com/KarelZe/lev/main/docs/assets/benchmark_ascii_dark.svg)

### Other Encodings

`lev` maintains its lead across all four CPython string-encoding kinds.

#### Latin-1

![Latin-1 benchmark – dark](https://raw.githubusercontent.com/KarelZe/lev/main/docs/assets/benchmark_latin_1_dark.svg)

#### CJK

![CJK benchmark – dark](https://raw.githubusercontent.com/KarelZe/lev/main/docs/assets/benchmark_cjk_dark.svg)

#### Emoji

![Emoji benchmark – dark](https://raw.githubusercontent.com/KarelZe/lev/main/docs/assets/benchmark_emoji_dark.svg)

## Contact

To get in contact, please open an issue or contact me via `github@markusbilz.com`.

