editdistpy (version 0.2.0) provides fast implementations of the Levenshtein and Damerau Optimal String Alignment (OSA) edit distance algorithms. Written in Cython/C++, it offers significant speed improvements for string comparison tasks. The library is actively maintained, with releases made periodically, the latest major version (0.2.0) released in February 2026.
pip install editdistpyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to calculate both Levenshtein and Damerau Optimal String Alignment (OSA) distances using `editdistpy`. It also highlights the use of `max_distance` for performance optimization, which returns -1 if the actual distance exceeds the specified maximum.
Upgrade Python to version 3.9 or higher.
Handle the `-1` return value appropriately, or explicitly pass `sys.maxsize` for an unbounded calculation.
Be aware of the distinction between Damerau OSA and the unrestricted Damerau-Levenshtein distance, and ensure it aligns with your specific use case. For typical typo correction, OSA is usually sufficient.
Upgrade to version 0.1.3 or later to ensure robust handling of `None` inputs and `max_distance=0`.
Install the package using pip: `pip install editdistpy` or `pip install -U editdistpy` to upgrade to the latest version. Ensure you are installing it in the correct Python environment (e.g., a virtual environment).
On Windows, install 'Microsoft Visual C++ Build Tools'. For other operating systems, ensure you have a C/C++ compiler installed (e.g., `build-essential` on Debian/Ubuntu, or Xcode Command Line Tools on macOS).
Import the specific edit distance algorithm (e.g., `levenshtein` or `damerau_osa`) from the `editdistpy` package: `from editdistpy import levenshtein` then use `levenshtein.distance(str1, str2)`.
Upgrade your Python environment to version 3.9 or newer to be compatible with `editdistpy` version 0.2.0.