turboshtein
Background
I didn't study computer science so bitwise operations have always been a bit of a gray area for me. I finally gave in and decided to spend some time reading up on the subject and ended up implementing the Myers bit-parallel algorithm[1] for computing Levenshtein edit distance. I was fairly happy with the results so I wrapped the original C code in Python and uploaded it to PyPI. Coincidentally, it's also pretty fast.
Usage
Install via PyPI:
pip install turboshtein
Or from source:
pip install .
Computing levenshtein edit distance between two strings:
>>> from turboshtein import levenshtein
>>> levenshtein("saturday", "sunday")
3
Note that there are several limitations, mainly:
- Max string length must be less than 64.
- ASCII or Latin-1 characters only.
Performance
Values represent the number of string pairs processed per second (higher is better).
Version 0.0.5
| library | version | turboshtein advantage | m=n=8 | m=n=16 | m=n=24 | m=n=32 | m=n=40 | m=n=48 | m=n=56 |
|---|---|---|---|---|---|---|---|---|---|
| turboshtein.levenshtein | 0.0.5 | --- | 19,685,039 | 13,094,009 | 9,949,417 | 7,949,915 | 6,488,589 | 5,269,281 | 4,605,111 |
| rapidfuzz.distance.Levenshtein.distance | 3.14.6 | 1.2x – 1.7x faster | 11,616,641 | 9,109,890 | 7,422,064 | 6,272,703 | 5,220,116 | 4,418,830 | 3,923,236 |
| Levenshtein.distance | 0.27.5 | 1.4x – 2.4x faster | 8,104,003 | 6,769,142 | 5,748,639 | 5,019,556 | 4,191,919 | 3,771,687 | 3,404,689 |
| jellyfish.levenshtein_distance | 1.3.0 | 12x – 82x faster | 1,649,960 | 549,253 | 294,319 | 138,237 | 95,645 | 72,144 | 56,138 |
| textdistance.levenshtein | 4.6.2 | 4.9x – 16x faster | 1,219,580 | 1,128,859 | 1,077,474 | 1,038,781 | 1,005,222 | 971,589 | 946,850 |
Test setup:
- Apple M3
- macOS 26.6.2
- Python 3.13
Version: 0.0.4
| library | version | m=n=8 | m=n=16 | m=n=24 | m=n=32 | m=n=40 | m=n=48 | m=n=56 |
|---|---|---|---|---|---|---|---|---|
| turboshtein.levenshtein | 0.0.4 | 7,625,612 | 6,134,367 | 5,160,757 | 4,455,692 | 3,897,966 | 3,477,885 | 3,147,237 |
| Levenshtein.distance | 0.20.5 | 6,448,035 | 5,335,239 | 4,556,680 | 4,034,226 | 3,550,695 | 3,211,664 | 2,910,581 |
| rapidfuzz.distance.Levenshtein.distance | 2.11.1 | 6,446,954 | 5,268,454 | 4,560,213 | 4,027,110 | 3,540,574 | 3,215,206 | 2,912,386 |
| jellyfish.levenshtein_distance | 0.9.0 | 3,823,843 | 1,494,087 | 718,785 | 399,693 | 262,541 | 183,554 | 135,081 |
| textdistance.levenshtein | 4.5.0 | 444,305 | 413,950 | 411,441 | 401,539 | 395,777 | 389,462 | 385,233 |
Test setup:
- XPS 15 9570
- Intel i7-8750H
- Fedora Linux 36 (Workstation Edition)
References
[1]: Gene Myers. 1999. A fast bit-vector algorithm for approximate string matching based on dynamic programming. J. ACM 46, 3 (May 1999), 395-415. https://doi.org/10.1145/316542.316550
Metadata
Release files for turboshtein 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| turboshtein-0.0.5.tar.gz | 10.8 kB | Without provenance | Details for turboshtein-0.0.5.tar.gz |
Built distributions (wheels)
Total release size: 152.7 kB
Release files / turboshtein-0.0.5.tar.gz
| Download URL | turboshtein-0.0.5.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e6afbbeb9b31ff587cd1f68e940173d7b3470b63d8f89ea8da1bd0164d95e36
|
|
BLAKE2b-256 checksum How to use checksums |
e2cd984b324bbb0016b961a9f6277583c0fd9b47e89956aaec57ed0c64a2caba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / turboshtein-0.0.5-cp313-cp313-win_amd64.whl
| Download URL | turboshtein-0.0.5-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 10.5 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6091fdf847901acb4942b40580358e60766fd086a20af456b4379590add47998
|
|
BLAKE2b-256 checksum How to use checksums |
513ef538b3e88a9fee13177241b040220971451ed8c5ee1adc6a926853e47109
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / turboshtein-0.0.5-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | turboshtein-0.0.5-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 16.9 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
54030e952378d22d8b174d46d6530af065d764f59cb359e88a224fd9583e1ae3
|
|
BLAKE2b-256 checksum How to use checksums |
08c294524d48c51e1e1bba4768abae2eb46f67c49835043c7633a43155343c03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / turboshtein-0.0.5-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | turboshtein-0.0.5-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 8.4 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5689dbecd03a8f5f5f35113aa5fa832ef36234f0fdbfc366d93e7b6d07463243
|
|
BLAKE2b-256 checksum How to use checksums |
05d544b253b03c37d1ce5bd89faed9962abf2e032ad2445bde3ed66a455149ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / turboshtein-0.0.5-cp312-cp312-win_amd64.whl
| Download URL | turboshtein-0.0.5-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 10.5 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
afe37b700738e90cede9365d7c88a7d31c68be4fff2268e63acb9cdc456cf807
|
|
BLAKE2b-256 checksum How to use checksums |
e2e335311d24a9a300757fda2b2c9a0b840bbf2dc88e588b2a1394a28b52ba42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / turboshtein-0.0.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | turboshtein-0.0.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 16.9 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
60dc3eafa1c3b37997d8e05c5529309a59d5e3e7c0f47f9caf4ceed9a776828c
|
|
BLAKE2b-256 checksum How to use checksums |
7b8a59cd1bb2fa94b5935aab4af64779c6e7c525708a2bdc78bb105396f8612d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / turboshtein-0.0.5-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | turboshtein-0.0.5-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 8.4 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ade2eedd678d84f19de4d486e192f587b1425ff1fab005b7357a8a22aca2d2c9
|
|
BLAKE2b-256 checksum How to use checksums |
5bff476fa5e5eb3ab680aa723887664fa39a8edf25e22c8cea2e1ad6fbda287b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / turboshtein-0.0.5-cp311-cp311-win_amd64.whl
| Download URL | turboshtein-0.0.5-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 10.4 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7ae9b90fc3d764cb16286ba535ef84a9154b2ded54dc4c3ffb19300cd54bd963
|
|
BLAKE2b-256 checksum How to use checksums |
3099f56c89ba0ebb53417c70e3e358f8bad7c3027ef5b16e8c50142554a3e8b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / turboshtein-0.0.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | turboshtein-0.0.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 16.8 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
9c53f6b46c70a68d965641666549bb455993eb28140887194c770d43de748557
|
|
BLAKE2b-256 checksum How to use checksums |
d207d61fd36e30602a2c5576c8bc967fe6a6442e8223652b810fdae9e21384cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / turboshtein-0.0.5-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | turboshtein-0.0.5-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 8.4 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
453194a0eb987cce24ee5291f7d2e8ba71cc2f46de24c6107112728b26879b16
|
|
BLAKE2b-256 checksum How to use checksums |
90d9f50e27eb235e7d315b37fd8bf238e07674c6f8fa83049f76aa725028847c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / turboshtein-0.0.5-cp310-cp310-win_amd64.whl
| Download URL | turboshtein-0.0.5-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 10.5 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
92e60d58b9d6c4daf37fe27e7c7f261155550bfe19d7eeedacbd161190576f13
|
|
BLAKE2b-256 checksum How to use checksums |
8f38dc33eeb32f52ea0b3c3db226a72be98ed2dbb061f413a0537c9d5a5c488c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / turboshtein-0.0.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | turboshtein-0.0.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 16.0 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
6ff0152e6c1396998da90cecb5d30fe23da653d7087fe9273c37b07f31657655
|
|
BLAKE2b-256 checksum How to use checksums |
40016a7ed5516b53815f5c3b2dcfea11887094185bae708e21fc1af756ead991
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / turboshtein-0.0.5-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | turboshtein-0.0.5-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 8.4 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
63abb0840ebd381362acced36096e9e43ee5cf1c753d0b8d25fa1ffeb9d0bed1
|
|
BLAKE2b-256 checksum How to use checksums |
05db629ca17744e5326375e2f187d0bb0ae90243fb5f73def0a1fb09e138db82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for turboshtein 0.0.5
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.