lev-rs 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lev_rs-0.2.4/.claude/agents/code-cartographer.md +42 -0
- lev_rs-0.2.4/.claude/agents/competitor-scout.md +38 -0
- lev_rs-0.2.4/.claude/agents/microarch-checker.md +46 -0
- lev_rs-0.2.4/.claude/agents/profile-runner.md +32 -0
- lev_rs-0.2.4/.claude/settings.json +22 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/.github/dependabot.yaml +4 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/.github/workflows/benchmark.yml +10 -5
- {lev_rs-0.2.2 → lev_rs-0.2.4}/.github/workflows/docs.yml +2 -2
- {lev_rs-0.2.2 → lev_rs-0.2.4}/.github/workflows/prek.yaml +2 -2
- {lev_rs-0.2.2 → lev_rs-0.2.4}/.github/workflows/release.yml +20 -36
- {lev_rs-0.2.2 → lev_rs-0.2.4}/.github/workflows/test.yml +3 -3
- {lev_rs-0.2.2 → lev_rs-0.2.4}/.gitignore +2 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/.vscode/settings.json +3 -1
- {lev_rs-0.2.2 → lev_rs-0.2.4}/AGENTS.md +34 -5
- {lev_rs-0.2.2 → lev_rs-0.2.4}/CHANGELOG.md +17 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/Cargo.lock +11 -11
- {lev_rs-0.2.2 → lev_rs-0.2.4}/Cargo.toml +1 -1
- {lev_rs-0.2.2 → lev_rs-0.2.4}/PKG-INFO +9 -10
- {lev_rs-0.2.2 → lev_rs-0.2.4}/README.md +7 -1
- {lev_rs-0.2.2 → lev_rs-0.2.4}/docs/assets/benchmark_ascii_dark.svg +219 -133
- {lev_rs-0.2.2 → lev_rs-0.2.4}/docs/assets/benchmark_ascii_light.svg +219 -133
- {lev_rs-0.2.2 → lev_rs-0.2.4}/docs/assets/benchmark_cjk_dark.svg +265 -279
- {lev_rs-0.2.2 → lev_rs-0.2.4}/docs/assets/benchmark_cjk_light.svg +265 -279
- {lev_rs-0.2.2 → lev_rs-0.2.4}/docs/assets/benchmark_emoji_dark.svg +212 -154
- {lev_rs-0.2.2 → lev_rs-0.2.4}/docs/assets/benchmark_emoji_light.svg +212 -154
- {lev_rs-0.2.2 → lev_rs-0.2.4}/docs/assets/benchmark_latin_1_dark.svg +264 -156
- {lev_rs-0.2.2 → lev_rs-0.2.4}/docs/assets/benchmark_latin_1_light.svg +264 -156
- lev_rs-0.2.4/docs/assets/benchmark_realistic_dark.svg +1283 -0
- lev_rs-0.2.4/docs/assets/benchmark_realistic_light.svg +1283 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/docs/index.md +10 -2
- {lev_rs-0.2.2 → lev_rs-0.2.4}/prek.toml +10 -1
- {lev_rs-0.2.2 → lev_rs-0.2.4}/pyproject.toml +8 -20
- lev_rs-0.2.4/scripts/benchmark.py +284 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/scripts/benchmark_by_length.py +105 -4
- {lev_rs-0.2.2 → lev_rs-0.2.4}/src/lib.rs +797 -117
- lev_rs-0.2.4/tests/conftest.py +21 -0
- lev_rs-0.2.4/tests/test_lev.py +401 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/uv.lock +8 -892
- lev_rs-0.2.4/version +1 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/zensical.toml +0 -4
- lev_rs-0.2.2/scripts/benchmark.py +0 -149
- lev_rs-0.2.2/scripts/install_dev.sh +0 -38
- lev_rs-0.2.2/tests/test_lev.py +0 -118
- lev_rs-0.2.2/version +0 -1
- {lev_rs-0.2.2 → lev_rs-0.2.4}/.cargo/config.toml +0 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/.gemini/settings.json +0 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/.github/CODEOWNERS +0 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/LICENSE +0 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/build.rs +0 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/docs/api.md +0 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/docs/overrides/partials/integrations/analytics/umami.html +0 -0
- {lev_rs-0.2.2 → lev_rs-0.2.4}/lev.pyi +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-cartographer
|
|
3
|
+
description: Maps the lev Rust source, identifies the hot function per CPython string kind, and reports algorithm, allocations, branch structure, and PyO3 boundary work. Read-only.
|
|
4
|
+
tools: Read, Glob, Grep
|
|
5
|
+
model: opus
|
|
6
|
+
---
|
|
7
|
+
You map the codebase. Never edit source files.
|
|
8
|
+
|
|
9
|
+
Deliverables, in this order:
|
|
10
|
+
|
|
11
|
+
1. **Entry-point map.** For each public Python function (`lev.distance`,
|
|
12
|
+
`lev.ratio`, anything else exposed via PyO3), trace the call path from
|
|
13
|
+
the `#[pyfunction]` down to the innermost DP loop. Note the file and
|
|
14
|
+
line range for each hop.
|
|
15
|
+
|
|
16
|
+
2. **Per-kind specialization.** CPython strings come in four kinds
|
|
17
|
+
(ASCII, UCS-1 Latin-1, UCS-2, UCS-4). For each kind, report:
|
|
18
|
+
- Is there a dedicated code path, or does everything funnel into one
|
|
19
|
+
generic implementation?
|
|
20
|
+
- How is the raw buffer accessed (PyUnicode_KIND + raw pointer, or
|
|
21
|
+
`to_str` with UTF-8 decode)?
|
|
22
|
+
- What integer width is the DP row using?
|
|
23
|
+
|
|
24
|
+
3. **Hot loop anatomy.** For the innermost distance loop:
|
|
25
|
+
- Algorithm (Wagner-Fischer, Myers bit-parallel, Ukkonen banded, other).
|
|
26
|
+
- Row width and reuse (allocated per call? thread-local? stack?).
|
|
27
|
+
- Branch structure of the min-of-three update.
|
|
28
|
+
- Any `unsafe`, `unreachable_unchecked`, SIMD intrinsics, or explicit
|
|
29
|
+
unrolling.
|
|
30
|
+
- Any early-exit conditions (max distance, length diff, common
|
|
31
|
+
prefix/suffix trim).
|
|
32
|
+
|
|
33
|
+
4. **PyO3 boundary work.** Any per-call cost outside the DP: argument
|
|
34
|
+
extraction, GIL handling, allocation for the return value, string kind
|
|
35
|
+
dispatch.
|
|
36
|
+
|
|
37
|
+
5. **Test/bench inventory.** List every criterion bench and every
|
|
38
|
+
`scripts/benchmark.py` scenario, one line each: name, inputs, what it
|
|
39
|
+
measures.
|
|
40
|
+
|
|
41
|
+
Format as markdown with file:line references in the form `src/lib.rs:42`.
|
|
42
|
+
Do not propose changes.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: competitor-scout
|
|
3
|
+
description: Reads rapidfuzz, edlib, and editdistance source to summarize the algorithms and low-level tricks each uses for Levenshtein distance. Returns a comparison table plus notable ideas not present in lev.
|
|
4
|
+
tools: Read, Glob, Grep, Bash, WebFetch
|
|
5
|
+
model: opus
|
|
6
|
+
---
|
|
7
|
+
You survey competing Levenshtein implementations. Read-only on our repo.
|
|
8
|
+
|
|
9
|
+
For each of rapidfuzz (C++), edlib (C++), editdistance (Cython):
|
|
10
|
+
1. Locate the source. If not already vendored somewhere in this repo, fetch
|
|
11
|
+
the relevant file(s) from GitHub via WebFetch. Prefer:
|
|
12
|
+
- rapidfuzz-cpp: `rapidfuzz/distance/Levenshtein_impl.hpp` and related.
|
|
13
|
+
- edlib: `edlib/src/edlib.cpp`.
|
|
14
|
+
- editdistance: `editdistance/_editdistance.h` / `.cpp`.
|
|
15
|
+
2. Identify the core algorithm and the specific tricks used:
|
|
16
|
+
- Bit-parallel (Myers / Hyyrö)? What word width, single-word vs
|
|
17
|
+
multi-word (block) variant?
|
|
18
|
+
- Banded / Ukkonen cutoff?
|
|
19
|
+
- Common prefix/suffix trimming?
|
|
20
|
+
- Length-based short-circuits?
|
|
21
|
+
- SIMD (SSE/AVX/NEON)?
|
|
22
|
+
- Per-encoding or per-alphabet-size specializations?
|
|
23
|
+
- Small-string special cases (len 0, 1, equal length)?
|
|
24
|
+
- Scratch buffer strategy (stack, thread-local, pool)?
|
|
25
|
+
3. Note any correctness subtleties (Unicode normalization, code point vs
|
|
26
|
+
code unit, surrogate handling).
|
|
27
|
+
|
|
28
|
+
Return two artifacts:
|
|
29
|
+
|
|
30
|
+
**Comparison table** — one row per library, columns for each trick above
|
|
31
|
+
(yes/no/details), plus a "notes" column.
|
|
32
|
+
|
|
33
|
+
**Ideas worth stealing** — a bulleted list of specific techniques used by
|
|
34
|
+
competitors that (based on your read of the code) are likely absent or
|
|
35
|
+
weaker in lev. Rank by expected impact on 100-char inputs. Do not propose
|
|
36
|
+
implementation — just name the idea and cite the competitor's file:line.
|
|
37
|
+
|
|
38
|
+
Do not edit lev's source.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: microarch-checker
|
|
3
|
+
description: Inspects generated assembly for lev's hot loop on Apple Silicon (aarch64), reports whether NEON is used, checks for spills and suboptimal codegen. Read-only.
|
|
4
|
+
tools: Read, Glob, Grep, Bash
|
|
5
|
+
model: opus
|
|
6
|
+
---
|
|
7
|
+
You inspect codegen. Never edit source files.
|
|
8
|
+
|
|
9
|
+
Setup:
|
|
10
|
+
- Target is aarch64-apple-darwin (Mac Mini M2 Pro benchmark box).
|
|
11
|
+
- Ensure `cargo-show-asm` is available: `cargo install cargo-show-asm` only
|
|
12
|
+
if the user has confirmed; otherwise fall back to
|
|
13
|
+
`RUSTFLAGS="--emit=asm" cargo build --release` and read the `.s` files
|
|
14
|
+
under `target/release/deps/`.
|
|
15
|
+
|
|
16
|
+
For the innermost distance function identified by code-cartographer (if
|
|
17
|
+
that report is available in the conversation, use it; otherwise find it
|
|
18
|
+
yourself via Grep for the DP loop):
|
|
19
|
+
|
|
20
|
+
1. Dump the assembly with `cargo asm --lib --rust --target aarch64-apple-darwin
|
|
21
|
+
<fully::qualified::path>` (or the emit-asm fallback). Save to
|
|
22
|
+
`/tmp/lev-hot.s`.
|
|
23
|
+
|
|
24
|
+
2. Report:
|
|
25
|
+
- Is NEON in use? (Look for `v0.16b`, `v0.8h`, `ld1`, `st1`, `umin`,
|
|
26
|
+
`smin`, `add v`, etc.) If scalar-only, say so plainly.
|
|
27
|
+
- Are the min-of-three updates vectorized, or done in scalar with
|
|
28
|
+
`csel` / `cmp` / `b.lt`?
|
|
29
|
+
- Register pressure: any stack spills in the inner loop
|
|
30
|
+
(`str`/`ldr` targeting `[sp, #...]`)?
|
|
31
|
+
- Loop structure: unrolled? bounds-checked on every iteration
|
|
32
|
+
(`bl __rust_panic` or similar in-loop)?
|
|
33
|
+
- Any surprising library calls inside the loop (memcpy, alloc, panic
|
|
34
|
+
handlers).
|
|
35
|
+
|
|
36
|
+
3. Cross-check against the Cargo release profile in `Cargo.toml`: `opt-level`,
|
|
37
|
+
`lto`, `codegen-units`, `panic`. Report current values and flag if any
|
|
38
|
+
are suboptimal for a hot numeric loop (but do not change them).
|
|
39
|
+
|
|
40
|
+
Return a markdown report:
|
|
41
|
+
- **Codegen summary** — 3-5 bullets, plain language.
|
|
42
|
+
- **Evidence** — 10-20 lines of the actual assembly with annotations.
|
|
43
|
+
- **Flags to consider** — profile settings or RUSTFLAGS worth testing in
|
|
44
|
+
a *separate* experiment. Explicitly do not recommend changing them here.
|
|
45
|
+
|
|
46
|
+
If tools are missing, report which and stop.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: profile-runner
|
|
3
|
+
description: Profiles scripts/benchmark.py and the criterion benches with samply and cargo flamegraph, returns top self-time frames per encoding. Read-only, never edits source.
|
|
4
|
+
tools: Bash, Read, Glob
|
|
5
|
+
model: haiku
|
|
6
|
+
---
|
|
7
|
+
You profile only. Never edit source files.
|
|
8
|
+
|
|
9
|
+
For each encoding kind in {ascii, latin1, cjk, emoji}:
|
|
10
|
+
|
|
11
|
+
1. Profile the Python-level benchmark for that kind under samply:
|
|
12
|
+
samply record -o profile-<kind>.json -- \
|
|
13
|
+
uv run scripts/benchmark.py --kind <kind> --save /tmp/bench-<kind>.json
|
|
14
|
+
If samply is not installed, report and stop — do not try to install it.
|
|
15
|
+
|
|
16
|
+
2. Profile the Rust-level criterion benches under cargo flamegraph, one
|
|
17
|
+
flamegraph per bench binary that exists in `benches/`:
|
|
18
|
+
cargo flamegraph -o flame-<bench>.svg --bench <bench>
|
|
19
|
+
Do not pass `--profile-time` — criterion may not recognize it and it
|
|
20
|
+
is not required for profiling. If a per-kind bench does not exist,
|
|
21
|
+
profile whichever benches do and note the coverage gap in your report.
|
|
22
|
+
If cargo-flamegraph is not installed, report and stop.
|
|
23
|
+
|
|
24
|
+
Return one markdown table per artifact:
|
|
25
|
+
| Frame | %self | %total | notes |
|
|
26
|
+
Include the top 5 frames by self-time. In the `notes` column flag anything
|
|
27
|
+
that looks like: PyO3 boundary work, UTF-8 decode, allocation, memcpy,
|
|
28
|
+
unexpected library functions.
|
|
29
|
+
|
|
30
|
+
End with a 3-bullet summary: (1) hottest single frame across all kinds,
|
|
31
|
+
(2) biggest per-kind difference, (3) anything that looks like low-hanging
|
|
32
|
+
fruit. Do not propose fixes — that is the main session's job.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/claude-code-settings.json",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"PostToolUse": [
|
|
5
|
+
{
|
|
6
|
+
"matcher": "Write|Edit|MultiEdit",
|
|
7
|
+
"hooks": [
|
|
8
|
+
{
|
|
9
|
+
"type": "command",
|
|
10
|
+
"command": "cd \"$CLAUDE_PROJECT_DIR\" && uv run --no-sync ruff check --fix . >&2 && uv run --no-sync ruff format . >&2 || exit 2",
|
|
11
|
+
"timeout": 60
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"type": "command",
|
|
15
|
+
"command": "cd \"$CLAUDE_PROJECT_DIR\" && cargo fmt >&2 || exit 2",
|
|
16
|
+
"timeout": 60
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -12,6 +12,8 @@ updates:
|
|
|
12
12
|
interval: "daily"
|
|
13
13
|
assignees:
|
|
14
14
|
- "KarelZe"
|
|
15
|
+
cooldown:
|
|
16
|
+
default-days: 7
|
|
15
17
|
# Maintain dependencies for GitHub Actions
|
|
16
18
|
- package-ecosystem: "github-actions"
|
|
17
19
|
directory: "/"
|
|
@@ -19,3 +21,5 @@ updates:
|
|
|
19
21
|
interval: "daily"
|
|
20
22
|
assignees:
|
|
21
23
|
- "KarelZe"
|
|
24
|
+
cooldown:
|
|
25
|
+
default-days: 7
|
|
@@ -13,14 +13,19 @@ on:
|
|
|
13
13
|
|
|
14
14
|
jobs:
|
|
15
15
|
benchmarks:
|
|
16
|
-
name: CodSpeed benchmarks
|
|
16
|
+
name: CodSpeed benchmarks (py${{ matrix.python-version }})
|
|
17
17
|
runs-on: ubuntu-latest
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
python-version: ["3.13", "3.14", "3.15"]
|
|
18
22
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
23
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
20
24
|
|
|
21
|
-
- uses: actions/setup-python@
|
|
25
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
22
26
|
with:
|
|
23
|
-
python-version:
|
|
27
|
+
python-version: ${{ matrix.python-version }}
|
|
28
|
+
allow-prereleases: true
|
|
24
29
|
|
|
25
30
|
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
|
|
26
31
|
|
|
@@ -30,7 +35,7 @@ jobs:
|
|
|
30
35
|
- name: Install benchmark deps
|
|
31
36
|
run: pip install pytest pytest-codspeed pytest-cov
|
|
32
37
|
|
|
33
|
-
- uses: CodSpeedHQ/action@
|
|
38
|
+
- uses: CodSpeedHQ/action@4296e51e7041e24dadb86d1d6e8b9320d223dbe8 # v5.0.3
|
|
34
39
|
with:
|
|
35
40
|
mode: simulation
|
|
36
41
|
token: ${{ secrets.CODSPEED_TOKEN }}
|
|
@@ -18,9 +18,9 @@ jobs:
|
|
|
18
18
|
build:
|
|
19
19
|
runs-on: ubuntu-latest
|
|
20
20
|
steps:
|
|
21
|
-
- uses: actions/checkout@
|
|
21
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
22
22
|
|
|
23
|
-
- uses: actions/setup-python@
|
|
23
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
24
24
|
with:
|
|
25
25
|
python-version: "3.13"
|
|
26
26
|
|
|
@@ -6,8 +6,8 @@ jobs:
|
|
|
6
6
|
prek:
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
steps:
|
|
9
|
-
- uses: actions/checkout@
|
|
9
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
|
|
10
10
|
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
|
|
11
11
|
with:
|
|
12
12
|
components: rustfmt
|
|
13
|
-
- uses: j178/prek-action@
|
|
13
|
+
- uses: j178/prek-action@4e14d07f9231acabce116ccfca13b13dd9755ece # v3.0.0
|
|
@@ -15,36 +15,20 @@ jobs:
|
|
|
15
15
|
runs-on: ubuntu-latest
|
|
16
16
|
strategy:
|
|
17
17
|
matrix:
|
|
18
|
-
|
|
19
|
-
- target: x86_64
|
|
20
|
-
# x86_64: explicit CPython paths to skip PyPy in the manylinux container.
|
|
21
|
-
args: >-
|
|
22
|
-
--release --out dist
|
|
23
|
-
--interpreter
|
|
24
|
-
/opt/python/cp310-cp310/bin/python
|
|
25
|
-
/opt/python/cp311-cp311/bin/python
|
|
26
|
-
/opt/python/cp312-cp312/bin/python
|
|
27
|
-
/opt/python/cp313-cp313/bin/python
|
|
28
|
-
/opt/python/cp314-cp314/bin/python
|
|
29
|
-
# FIXME: currently disabled as paths cannot be found.
|
|
30
|
-
# - target: aarch64
|
|
31
|
-
# # aarch64: explicit CPython paths (cross-compiled).
|
|
32
|
-
# # Consistent with x86_64 to ensure specific versions and skip PyPy.
|
|
33
|
-
# args: >-
|
|
34
|
-
# --release --out dist
|
|
35
|
-
# --interpreter
|
|
36
|
-
# /opt/python/cp310-cp310/bin/python
|
|
37
|
-
# /opt/python/cp311-cp311/bin/python
|
|
38
|
-
# /opt/python/cp312-cp312/bin/python
|
|
39
|
-
# /opt/python/cp313-cp313/bin/python
|
|
40
|
-
# /opt/python/cp314-cp314/bin/python
|
|
18
|
+
target: [x86_64, aarch64]
|
|
41
19
|
steps:
|
|
42
|
-
- uses: actions/checkout@
|
|
20
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
43
21
|
- uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
|
|
44
22
|
with:
|
|
45
23
|
target: ${{ matrix.target }}
|
|
46
24
|
manylinux: auto
|
|
47
|
-
|
|
25
|
+
# Version-only specifiers (not full paths). In the manylinux-cross
|
|
26
|
+
# container these resolve via sysconfig data files, which lets the
|
|
27
|
+
# aarch64 build read interpreter metadata without exec'ing the
|
|
28
|
+
# aarch64 binaries on the x86_64 host.
|
|
29
|
+
args: >-
|
|
30
|
+
--release --out dist
|
|
31
|
+
-i python3.10 python3.11 python3.12 python3.13 python3.14
|
|
48
32
|
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
49
33
|
with:
|
|
50
34
|
name: wheels-linux-${{ matrix.target }}
|
|
@@ -54,8 +38,8 @@ jobs:
|
|
|
54
38
|
name: Build — Windows (x64)
|
|
55
39
|
runs-on: windows-latest
|
|
56
40
|
steps:
|
|
57
|
-
- uses: actions/checkout@
|
|
58
|
-
- uses: actions/setup-python@
|
|
41
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
42
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
59
43
|
with:
|
|
60
44
|
python-version: |
|
|
61
45
|
3.10
|
|
@@ -76,8 +60,8 @@ jobs:
|
|
|
76
60
|
name: Build — macOS (universal2)
|
|
77
61
|
runs-on: macos-latest
|
|
78
62
|
steps:
|
|
79
|
-
- uses: actions/checkout@
|
|
80
|
-
- uses: actions/setup-python@
|
|
63
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
64
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
81
65
|
with:
|
|
82
66
|
python-version: |
|
|
83
67
|
3.10
|
|
@@ -98,7 +82,7 @@ jobs:
|
|
|
98
82
|
name: Build — sdist
|
|
99
83
|
runs-on: ubuntu-latest
|
|
100
84
|
steps:
|
|
101
|
-
- uses: actions/checkout@
|
|
85
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
102
86
|
- uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
|
|
103
87
|
with:
|
|
104
88
|
command: sdist
|
|
@@ -116,12 +100,12 @@ jobs:
|
|
|
116
100
|
permissions:
|
|
117
101
|
id-token: write
|
|
118
102
|
steps:
|
|
119
|
-
- uses: actions/download-artifact@
|
|
103
|
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
120
104
|
with:
|
|
121
105
|
pattern: wheels-*
|
|
122
106
|
merge-multiple: true
|
|
123
107
|
path: dist
|
|
124
|
-
- uses: pypa/gh-action-pypi-publish@
|
|
108
|
+
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1
|
|
125
109
|
with:
|
|
126
110
|
repository-url: https://test.pypi.org/legacy/
|
|
127
111
|
|
|
@@ -133,12 +117,12 @@ jobs:
|
|
|
133
117
|
permissions:
|
|
134
118
|
id-token: write
|
|
135
119
|
steps:
|
|
136
|
-
- uses: actions/download-artifact@
|
|
120
|
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
137
121
|
with:
|
|
138
122
|
pattern: wheels-*
|
|
139
123
|
merge-multiple: true
|
|
140
124
|
path: dist
|
|
141
|
-
- uses: pypa/gh-action-pypi-publish@
|
|
125
|
+
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1
|
|
142
126
|
|
|
143
127
|
github-release:
|
|
144
128
|
name: GitHub Release
|
|
@@ -147,12 +131,12 @@ jobs:
|
|
|
147
131
|
permissions:
|
|
148
132
|
contents: write
|
|
149
133
|
steps:
|
|
150
|
-
- uses: actions/download-artifact@
|
|
134
|
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
151
135
|
with:
|
|
152
136
|
pattern: wheels-*
|
|
153
137
|
merge-multiple: true
|
|
154
138
|
path: dist
|
|
155
|
-
- uses: softprops/action-gh-release@
|
|
139
|
+
- uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
|
|
156
140
|
with:
|
|
157
141
|
files: dist/*
|
|
158
142
|
generate_release_notes: true
|
|
@@ -16,16 +16,16 @@ jobs:
|
|
|
16
16
|
runs-on: ubuntu-latest
|
|
17
17
|
strategy:
|
|
18
18
|
matrix:
|
|
19
|
-
python-version: ["3.
|
|
19
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
20
20
|
|
|
21
21
|
steps:
|
|
22
|
-
- uses: actions/checkout@
|
|
22
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
23
23
|
|
|
24
24
|
- name: Set up Rust
|
|
25
25
|
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
|
|
26
26
|
|
|
27
27
|
- name: Set up Python ${{ matrix.python-version }}
|
|
28
|
-
uses: actions/setup-python@
|
|
28
|
+
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
29
29
|
with:
|
|
30
30
|
python-version: ${{ matrix.python-version }}
|
|
31
31
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cSpell.words": [
|
|
3
3
|
"Bilz",
|
|
4
|
+
"cooldown",
|
|
4
5
|
"Damerau",
|
|
5
6
|
"duftify",
|
|
6
7
|
"geht",
|
|
7
|
-
"Hyyrö's",
|
|
8
8
|
"Hyyrö",
|
|
9
|
+
"Hyyrö's",
|
|
9
10
|
"labelrotation",
|
|
10
11
|
"manylinux",
|
|
11
12
|
"Mathers",
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
"pytest",
|
|
18
19
|
"rapidfuzz",
|
|
19
20
|
"résumé",
|
|
21
|
+
"standalone",
|
|
20
22
|
"woulda",
|
|
21
23
|
"xticklabels",
|
|
22
24
|
"xticks",
|
|
@@ -9,17 +9,46 @@ prefer Rust-side optimizations over Python wrappers.
|
|
|
9
9
|
## Environment Setup
|
|
10
10
|
- Python >= 3.10
|
|
11
11
|
- Install: `uv sync --all-extras`
|
|
12
|
-
- After editing Rust, rebuild the extension: `
|
|
12
|
+
- After editing Rust, rebuild the extension: `uv run maturin develop --release`
|
|
13
|
+
|
|
14
|
+
## Performance workflow
|
|
15
|
+
|
|
16
|
+
All performance changes follow this loop. One change per experiment,
|
|
17
|
+
measured on the same hardware, kept only if it wins.
|
|
18
|
+
|
|
19
|
+
1. Pin a baseline before any change:
|
|
20
|
+
- Python-level:
|
|
21
|
+
`uv run scripts/benchmark.py --save baselines/<name>.json`
|
|
22
|
+
Add `--kind ascii` (or `latin1`, `cjk`, `emoji`, `realistic`) to baseline a
|
|
23
|
+
single string kind instead of all five.
|
|
24
|
+
- Rust-level (if criterion benches exist for the change surface):
|
|
25
|
+
`cargo bench -- --save-baseline <name>`
|
|
26
|
+
2. State a single, testable hypothesis before editing (e.g. "prefix/suffix
|
|
27
|
+
trim removes ~30% of DP work on ASCII-100"). One change per experiment.
|
|
28
|
+
3. Re-run the same benchmark on identical hardware, quiet system, `taskset`
|
|
29
|
+
or `sudo nice -n -20` where reasonable. Report median + IQR, not mean.
|
|
30
|
+
4. If the change is under 3% or within noise on every kind, REVERT.
|
|
31
|
+
Do not commit tuning that only wins in one microbenchmark.
|
|
32
|
+
5. Verify correctness against the property tests and a diff test vs.
|
|
33
|
+
rapidfuzz / edlib on random inputs before keeping any win.
|
|
34
|
+
6. Check codegen for the hot loop with `cargo asm` (or `--emit=asm`) when
|
|
35
|
+
claiming SIMD or auto-vectorization wins.
|
|
36
|
+
7. Never edit the release profile in `Cargo.toml` (LTO, codegen-units,
|
|
37
|
+
panic) as part of an algorithmic experiment. Separate PR.
|
|
38
|
+
|
|
39
|
+
Profiling is a read-only step and is delegated to the `profile-runner`
|
|
40
|
+
sub-agent (`.claude/agents/profile-runner.md`). It uses samply for the
|
|
41
|
+
Python-level benchmark and cargo flamegraph for the criterion benches;
|
|
42
|
+
neither needs `--profile-time`.
|
|
13
43
|
|
|
14
44
|
## Testing
|
|
15
45
|
- Python: `pytest tests/`
|
|
16
46
|
- Rust: `cargo test`
|
|
17
|
-
- Rust changes require a rebuild before pytest will pick them up. You can trigger a rebuild with `
|
|
47
|
+
- Rust changes require a rebuild before pytest will pick them up. You can trigger a rebuild with `uv run maturin develop --release`.
|
|
18
48
|
|
|
19
49
|
## Benchmarking
|
|
20
|
-
-
|
|
21
|
-
- Compare
|
|
22
|
-
- Compare across string lengths: `uv run python scripts/benchmark_by_length.py`
|
|
50
|
+
- Compare against other libraries: `uv run scripts/benchmark.py`
|
|
51
|
+
- Compare across string lengths: `uv run scripts/benchmark_by_length.py`
|
|
23
52
|
- For performance-critical changes, run `benchmark.py` before and after,
|
|
24
53
|
then diff `benchmark_results.json`.
|
|
25
54
|
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## 0.2.4 (2026-08-25)
|
|
2
|
+
|
|
3
|
+
### Perf
|
|
4
|
+
|
|
5
|
+
- improve performance on long cjk and emoji strings🚀 (#136)
|
|
6
|
+
|
|
7
|
+
## 0.2.3 (2026-07-09)
|
|
8
|
+
|
|
9
|
+
### Fix
|
|
10
|
+
|
|
11
|
+
- correct typo in project.description🐞 (#106)
|
|
12
|
+
|
|
13
|
+
### Perf
|
|
14
|
+
|
|
15
|
+
- improve performance on exceptionally long strings🚀 (#131)
|
|
16
|
+
- improve speed for >= python 3.14🚀 (#129)
|
|
17
|
+
|
|
1
18
|
## 0.2.2 (2026-05-05)
|
|
2
19
|
|
|
3
20
|
### Perf
|
|
@@ -10,7 +10,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
|
10
10
|
|
|
11
11
|
[[package]]
|
|
12
12
|
name = "lev"
|
|
13
|
-
version = "0.2.
|
|
13
|
+
version = "0.2.4"
|
|
14
14
|
dependencies = [
|
|
15
15
|
"pyo3",
|
|
16
16
|
"pyo3-build-config",
|
|
@@ -18,9 +18,9 @@ dependencies = [
|
|
|
18
18
|
|
|
19
19
|
[[package]]
|
|
20
20
|
name = "libc"
|
|
21
|
-
version = "0.2.
|
|
21
|
+
version = "0.2.189"
|
|
22
22
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
23
|
-
checksum = "
|
|
23
|
+
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
|
24
24
|
|
|
25
25
|
[[package]]
|
|
26
26
|
name = "once_cell"
|
|
@@ -30,15 +30,15 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
|
30
30
|
|
|
31
31
|
[[package]]
|
|
32
32
|
name = "portable-atomic"
|
|
33
|
-
version = "1.
|
|
33
|
+
version = "1.15.0"
|
|
34
34
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
35
|
-
checksum = "
|
|
35
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
36
36
|
|
|
37
37
|
[[package]]
|
|
38
38
|
name = "proc-macro2"
|
|
39
|
-
version = "1.0.
|
|
39
|
+
version = "1.0.107"
|
|
40
40
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
41
|
-
checksum = "
|
|
41
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
42
42
|
dependencies = [
|
|
43
43
|
"unicode-ident",
|
|
44
44
|
]
|
|
@@ -103,18 +103,18 @@ dependencies = [
|
|
|
103
103
|
|
|
104
104
|
[[package]]
|
|
105
105
|
name = "quote"
|
|
106
|
-
version = "1.0.
|
|
106
|
+
version = "1.0.47"
|
|
107
107
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
108
|
-
checksum = "
|
|
108
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
109
109
|
dependencies = [
|
|
110
110
|
"proc-macro2",
|
|
111
111
|
]
|
|
112
112
|
|
|
113
113
|
[[package]]
|
|
114
114
|
name = "syn"
|
|
115
|
-
version = "2.0.
|
|
115
|
+
version = "2.0.119"
|
|
116
116
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
117
|
-
checksum = "
|
|
117
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
118
118
|
dependencies = [
|
|
119
119
|
"proc-macro2",
|
|
120
120
|
"quote",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lev-rs
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Classifier: Development Status :: 3 - Alpha
|
|
5
5
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
6
6
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -13,12 +13,6 @@ Classifier: Intended Audience :: Information Technology
|
|
|
13
13
|
Classifier: Intended Audience :: Science/Research
|
|
14
14
|
Classifier: Topic :: Scientific/Engineering
|
|
15
15
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
-
Requires-Dist: edlib ; extra == 'benchmark'
|
|
17
|
-
Requires-Dist: editdistance>=0.8.1 ; extra == 'benchmark'
|
|
18
|
-
Requires-Dist: matplotlib>=3.10.9 ; extra == 'benchmark'
|
|
19
|
-
Requires-Dist: matplotx>=0.3.10 ; extra == 'benchmark'
|
|
20
|
-
Requires-Dist: numpy>=2.0 ; extra == 'benchmark'
|
|
21
|
-
Requires-Dist: rapidfuzz>=3.14.5 ; extra == 'benchmark'
|
|
22
16
|
Requires-Dist: commitizen ; extra == 'dev'
|
|
23
17
|
Requires-Dist: maturin ; extra == 'dev'
|
|
24
18
|
Requires-Dist: prek ; extra == 'dev'
|
|
@@ -28,11 +22,10 @@ Requires-Dist: pytest ; extra == 'dev'
|
|
|
28
22
|
Requires-Dist: ruff ; extra == 'dev'
|
|
29
23
|
Requires-Dist: zensical ; extra == 'docs'
|
|
30
24
|
Requires-Dist: mkdocstrings[python] ; extra == 'docs'
|
|
31
|
-
Provides-Extra: benchmark
|
|
32
25
|
Provides-Extra: dev
|
|
33
26
|
Provides-Extra: docs
|
|
34
27
|
License-File: LICENSE
|
|
35
|
-
Summary:
|
|
28
|
+
Summary: An extremely fast Python library for the Levenshtein distance and similarity ratio, written in Rust 🦀.
|
|
36
29
|
Keywords: distance,levenshtein,strings
|
|
37
30
|
Author-email: Markus Bilz <github@markusbilz.com>
|
|
38
31
|
Requires-Python: >=3.10
|
|
@@ -79,7 +72,7 @@ For more details on the API see the [API Reference](https://karelze.github.io/le
|
|
|
79
72
|
[edlib](https://github.com/Martinsos/edlib). We excluded slower implementations like
|
|
80
73
|
[pylev](https://github.com/toastdriven/pylev/tree/main) and [python-Levenshtein](https://github.com/ztane/python-Levenshtein).
|
|
81
74
|
|
|
82
|
-
> Benchmarks were run on an Apple Mac Mini M2 Pro (macOS 26.2) using Python 3.13.
|
|
75
|
+
> Benchmarks were run on an Apple Mac Mini M2 Pro (macOS 26.2) using Python 3.13. The ASCII, Latin-1, CJK, and Emoji pairs are exactly 100 characters long; the realistic-text pair is natural-length prose. Results represent the total wall time for 1,000 repetitions using Python's `timeit`. To reproduce, run [`uv run scripts/benchmark.py`](https://github.com/KarelZe/lev/blob/main/scripts/benchmark.py).
|
|
83
76
|
|
|
84
77
|
### ASCII
|
|
85
78
|
|
|
@@ -103,6 +96,12 @@ For more details on the API see the [API Reference](https://karelze.github.io/le
|
|
|
103
96
|
|
|
104
97
|

|
|
105
98
|
|
|
99
|
+
### Realistic Text
|
|
100
|
+
|
|
101
|
+
This pair is a short customer support message with a handful of natural typos.
|
|
102
|
+
|
|
103
|
+

|
|
104
|
+
|
|
106
105
|
## Contact
|
|
107
106
|
|
|
108
107
|
To get in contact, please open an issue or contact me via `github@markusbilz.com`.
|
|
@@ -37,7 +37,7 @@ For more details on the API see the [API Reference](https://karelze.github.io/le
|
|
|
37
37
|
[edlib](https://github.com/Martinsos/edlib). We excluded slower implementations like
|
|
38
38
|
[pylev](https://github.com/toastdriven/pylev/tree/main) and [python-Levenshtein](https://github.com/ztane/python-Levenshtein).
|
|
39
39
|
|
|
40
|
-
> Benchmarks were run on an Apple Mac Mini M2 Pro (macOS 26.2) using Python 3.13.
|
|
40
|
+
> Benchmarks were run on an Apple Mac Mini M2 Pro (macOS 26.2) using Python 3.13. The ASCII, Latin-1, CJK, and Emoji pairs are exactly 100 characters long; the realistic-text pair is natural-length prose. Results represent the total wall time for 1,000 repetitions using Python's `timeit`. To reproduce, run [`uv run scripts/benchmark.py`](https://github.com/KarelZe/lev/blob/main/scripts/benchmark.py).
|
|
41
41
|
|
|
42
42
|
### ASCII
|
|
43
43
|
|
|
@@ -61,6 +61,12 @@ For more details on the API see the [API Reference](https://karelze.github.io/le
|
|
|
61
61
|
|
|
62
62
|

|
|
63
63
|
|
|
64
|
+
### Realistic Text
|
|
65
|
+
|
|
66
|
+
This pair is a short customer support message with a handful of natural typos.
|
|
67
|
+
|
|
68
|
+

|
|
69
|
+
|
|
64
70
|
## Contact
|
|
65
71
|
|
|
66
72
|
To get in contact, please open an issue or contact me via `github@markusbilz.com`.
|