Skip to main content

A pure Python Levenshtein implementation that’s not freaking GPL’d.

Based off the Wikipedia code samples at http://en.wikipedia.org/wiki/Levenshtein_distance.

Requirements

  • Python 2.7.X, Python 3.3+ or PyPy 1.6.0+

Usage

Usage is fairly straightforward:

import pylev
distance = pylev.levenshtein('kitten', 'sitting')
assert distance == 3

License

New BSD.

Tests

Setup:

$ git clone https://github.com/toastdriven/pylev.git
$ cd pylev

Running:

$ python -m unittest tests
https://travis-ci.com/toastdriven/pylev.svg?branch=main

Version History

  • v1.4.0

    • Updated for current versions of Python

    • Integrated a better Travis matrix. Thanks to @grainert!

    • Fixed mistaken docs about the assert. Thanks to @adamchainz!

    • Reorganized the package.

    • Blacked all the source code.

  • v1.3.0

    • Implemented a considerably faster variants (orders of magnitude).

    • Tested & working on Python 2.7.4, Python 3.3.1 & PyPy 1.9.0.

  • v1.2.0

    • Fixed all incorrect spellings of “Levenshtein” (there’s no “c” in it).

    • Old methods are aliased for backward-compatibility.

  • v1.1.0

    • Implemented a much faster variant (several orders of magnitude).

    • The older variant was renamed to classic_levenschtein.

    • Tested & working on Python 3.3 & PyPy 1.6.0 as well.

  • v1.0.2

    • Python packaging is REALLY hard. Including the README this time.

  • v1.0.1

    • Python packaging is hard. Including the README this time.

  • v1.0.0

    • Initial release, just the naive implementation of Levenshtein.

Release files for pylev 1.4.0

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

Source distribution (sdist)

Source distribution for pylev 1.4.0
File Size Uploaded
pylev-1.4.0.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pylev 1.4.0
File Interpreter ABI Platform
pylev-1.4.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 10.8 kB

Release files / pylev-1.4.0.tar.gz

Download URL pylev-1.4.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9e77e941042ad3a4cc305dcdf2b2dec1aec2fbe3dd9015d2698ad02b173006d1
BLAKE2b-256 checksum
How to use checksums
11f2404d2bfa30fb4ee7c7a7435d593f9f698b25d191cafec69dd0c726f02f11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.4

Release files / pylev-1.4.0-py2.py3-none-any.whl

Download URL pylev-1.4.0-py2.py3-none-any.whl
Size 6.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7b2e2aa7b00e05bb3f7650eb506fc89f474f70493271a35c242d9a92188ad3dd
BLAKE2b-256 checksum
How to use checksums
047895cfe72991d22994f0ec5a3b742b31c95a28344d33e06b69406b68398a29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.4

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

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