Skip to main content

levenshtein-pa

Origin & Attribution

  • Inspired by: python-Levenshtein & Python's difflib (edit-distance API) + standard 64-bit FNV-1a specification.
  • Implementation: 100% clean-room reimplementation from scratch in pure Pa (.pa) — zero C/C++ boilerplate, zero garbage collection, deterministic stack/RAII memory layout, compiled via LLVM -O2.
  • License: MIT

Benchmark vs. Original

Workload: Fuzzy match filter (dist <= 4) of a 36-byte query against 10,000 candidate strings (~40 bytes each, 1,000 matches), verified for 100% identical (index, distance) output across all three runs.
Environment: Linux x86-64 · CPython 3.12 · pac 0.1.0 --mode prod · isolated subprocess per mode, 3-run median (time.perf_counter + resource.getrusage Peak RSS).

Implementation Runtime Median Time Speedup Peak RSS
Pure Python (for loop) CPython 2,532.66 ms 1.0x 17.7 MB
levenshtein-pa single-call (levenshtein_pa.levenshtein) CPython + .so 62.60 ms 40.5x 17.7 MB
loop-template batch (custom_batch.filter_batch) CPython + .so 4.78 ms 530.0x 19.1 MB
Pure Pa Standalone (pac build --mode prod) Native (No Python) 7.52 ms 336.8x 1.7 MB

Note: CPython rows include the ~17 MB interpreter baseline; the +1.4 MB in loop-template mode comes from the contiguous UTF-8 corpus buffer, CSR offsets, and pre-allocated zero-copy output arrays (zero per-item PyObject* allocations inside the native loop). The Pure Pa Standalone row includes full OS process startup (fork/exec) and drops Peak RSS to 1.7 MB with zero Python runtime.

Reproduce locally:

python benchmarks/bench_levenshtein.py

Quick Usage

1. Python (Pre-compiled .so / .pyd, Zero ctypes)

pip install levenshtein-pa
import levenshtein_pa

levenshtein_pa.levenshtein("kitten", "sitting")                            # 3
levenshtein_pa.levenshtein_bytes(b"kitten", b"sitting")                    # 3
levenshtein_pa.fnv1a_64("foobar")                                          # 0x85944171f73967e8
levenshtein_pa.levenshtein_batch("kitten", ["sitting", "mitten", "bitten"])  # [3, 1, 1]

2. Pure Pa Standalone (Zero Python Runtime)

After pip install levenshtein-pa (via the pa_lang.libs entry point) or with -I packages/levenshtein-pa/pa:

from levenshtein import levenshtein_str, fnv1a_64_str
pac build --mode prod main.pa -o app

3. Custom Batch Loop (loop-template/)

To eliminate Python for-loop overhead on custom filtering/scoring workloads, edit only the marked loop body in loop-template/custom_batch.pa and compile directly to an importable .so:

cd packages/levenshtein-pa/loop-template
pac build --shared --mode prod -I ../pa custom_batch.pa -o custom_batch.so

Metadata

Release files for levenshtein-pa 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for levenshtein-pa 0.1.1
File Actions
levenshtein_pa-0.1.1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for levenshtein_pa-0.1.1-cp311-abi3-win_amd64.whl
levenshtein_pa-0.1.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details for levenshtein_pa-0.1.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
levenshtein_pa-0.1.1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for levenshtein_pa-0.1.1-cp311-abi3-macosx_11_0_arm64.whl
levenshtein_pa-0.1.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for levenshtein_pa-0.1.1-cp310-cp310-win_amd64.whl
levenshtein_pa-0.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for levenshtein_pa-0.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
levenshtein_pa-0.1.1-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for levenshtein_pa-0.1.1-cp310-cp310-macosx_11_0_arm64.whl

Total release size: 85.8 kB

Release files / levenshtein_pa-0.1.1-cp311-abi3-win_amd64.whl

Download URL levenshtein_pa-0.1.1-cp311-abi3-win_amd64.whl
Size 14.9 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2251fcbb2359d03702ef780a5e056a88ebd168a70e6e1ad9651b07f2da2a6b3a
BLAKE2b-256 checksum
How to use checksums
4fc6985415f63162e5d660276e8a1495f88d26e55957350d0a3171e3b6980a01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / levenshtein_pa-0.1.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL levenshtein_pa-0.1.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 15.1 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
571db9c1b3192df1dff9098c1ea94603958f8604743823d075b4b3c4c368e51b
BLAKE2b-256 checksum
How to use checksums
e486a3da1ee1fb2fdcc614895d0570eb46145b6f2f8ece0b2fac3ac9f2ff5c9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / levenshtein_pa-0.1.1-cp311-abi3-macosx_11_0_arm64.whl

Download URL levenshtein_pa-0.1.1-cp311-abi3-macosx_11_0_arm64.whl
Size 12.8 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
92d0597d226dc1cbda122daba4e6394bc635404de7235a577dcfc6d377266e0d
BLAKE2b-256 checksum
How to use checksums
f72c765cc11a5cd18ecdc14e0731909f0eba66af1c471b148c680288f96b48f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / levenshtein_pa-0.1.1-cp310-cp310-win_amd64.whl

Download URL levenshtein_pa-0.1.1-cp310-cp310-win_amd64.whl
Size 15.0 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
21a93d00a9392f4e017a7218801cc1ee46a82790ea17d34d5345ea685dbb7b8b
BLAKE2b-256 checksum
How to use checksums
0c67bdc5097e9fc98c63d502ad151b37794054dd7c672d29587abc1b05654670
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / levenshtein_pa-0.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL levenshtein_pa-0.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 15.1 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
42bc2a8d9e6469e1a745530c5a729a6f2705c7e77481f6d89926cc435b130c81
BLAKE2b-256 checksum
How to use checksums
81b26488b47b7c4629f555908eff63357428a6edf8f9332a0652ecedc4dbd4ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / levenshtein_pa-0.1.1-cp310-cp310-macosx_11_0_arm64.whl

Download URL levenshtein_pa-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Size 12.9 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
11b85786a6edbef34f1fc9ca694fd5156f00d22a60c1f58ce7eaef1d4d715c7b
BLAKE2b-256 checksum
How to use checksums
a1d2774d389f3475a52bbc22999031d6fb539ad3861c509a04921956b63760ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for levenshtein-pa 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for levenshtein_pa-0.1.1-cp311-abi3-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

6 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page