Polyleven is a hyper-fast Python library for computing Levenshtein distance, implemented in C for optimal performance. It is designed to be efficient for comparing both short and long string inputs, is stand-alone with no external Python dependencies, and is distributed under the MIT License. The current version is 0.11.0, released on February 9, 2026, indicating an active release cadence.
pip install polylevenVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import the `levenshtein` function and use it to calculate the Levenshtein distance between two strings. It also shows how to leverage the optional `max_threshold` argument to improve performance, especially when only interested in distances below a certain value.
Call `levenshtein('string1', 'string2', k=max_threshold)` where `max_threshold` is the maximum relevant distance. For example, `levenshtein('abcde', 'xxxxx', 2)` would return `3` as the actual distance (5) is greater than the threshold (2).Verify the license (MIT for v0.7+) to ensure compatibility with your project's licensing requirements. If strict adherence to Public Domain is necessary, ensure usage of versions prior to 0.7.
When designing for maximum performance and a small distance is expected or acceptable, prioritize using a `max_threshold` value of 1 or 2.
Install the library using pip: `pip install polyleven`
Ensure your system has the necessary build tools and C/C++ runtime libraries. Try reinstalling 'polyleven' in a clean environment: `pip uninstall polyleven` then `pip install polyleven`. If on Linux, ensure `gcc` and `g++` are installed, and consider updating system libraries.
The correct function name for calculating Levenshtein distance is `levenshtein`. Correct your code to `from polyleven import levenshtein` and use `levenshtein(str1, str2)`.
Review your function call and provide only two string arguments (the strings to compare) and an optional third integer argument for the maximum distance threshold, e.g., `levenshtein('string1', 'string2')` or `levenshtein('string1', 'string2', max_distance_int)`.No dependency data recorded yet.