Distance
Utilities for comparing sequences
What it is and what it does
Distance is a sequence comparison library that implements several standard metrics for measuring similarity or difference between sequences—strings, tuples, or lists. It provides Levenshtein (edit distance), Hamming, Jaccard, and Sorensen metrics, all in pure Python, with optional C implementations for speed. The library also includes convenience functions like fast_comp for quick approximate distance checks and iterators for filtering large lists of sequences by similarity to a reference.
The package is designed for tasks like spell-checking, fuzzy matching, and finding similar items in collections. It has no runtime dependencies and can work entirely in Python, though building the C extension requires a compiler and Python development headers. The package is no longer maintained; its last release was in 2013-11-21.
Use it for:
- Spell-checking or autocorrect: find candidate words close to a misspelled input using Levenshtein distance.
- Fuzzy string matching: identify similar records in datasets where exact matches fail.
- Sentence or document similarity: compare sequences of tokens to find related text passages.
- Filtering large lists: use ilevenshtein or ifast_comp to efficiently find items within a distance threshold of a reference sequence.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Computes distance metrics (Levenshtein, Hamming, Jaccard, Sorensen) between arbitrary sequences, with pure Python implementations and optional C extensions for performance.
Yes, with conditions. The package is stable and has no known vulnerabilities, but it is abandoned and targets Python 3.3. Use it if you need a lightweight, dependency-free sequence distance library and can accept that it will not receive updates. If you need the C extension, expect build friction on modern systems. For new projects, consider whether a maintained alternative better fits your Python version and support expectations.
Install
distance on PyPI
pip
pip install distanceuv
uv add distancepoetry
poetry add distanceInstalling Distance
Before you install
High install friction: requires a C compiler and Python development headers if you want the C extension. The package is abandoned (last release 2013-11-21, last commit 2019-10-31), so expect no maintenance or updates.
License in practice
Licensed under GPL (copyleft); using this package in proprietary code requires your work to be GPL-compatible or released under a compatible license.
Quickstart
pip install distance
import distance
# Compare two strings
result = distance.levenshtein("lenvestein", "levenshtein")
print(result) # Output: 3
# Normalized Hamming distance
norm_result = distance.hamming("fat", "cat", normalized=True)
print(norm_result)
If you want the C extension, you need a C compiler (GCC on Linux/Mac, MSVC on Windows) and Python development headers (python-dev package on Debian-like systems). The package targets Python 3.3; compatibility with modern Python versions is unverified.
Verify before relying
- Whether the C extension builds successfully on modern Python versions (package targets Python 3.3)
- Current compatibility with Python versions beyond 3.3 and whether the package works on modern systems
- Whether the pure Python fallback is reliable enough for production use without the C extension
Package facts
| License | UNKNOWN (copyleft) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 4,649 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 690,153/month — #5,332 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: Distance-0.1.3.tar.gz
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
textdistanceComputes distance and similarity between text…
permissive · top 5,000 on PyPI
strsimpyImplements a dozen string similarity and…
permissive · top 15,000 on PyPI
editdistanceComputes the edit distance (Levenshtein…
permissive · top 5,000 on PyPI
python-LevenshteinComputes Levenshtein edit distance, string…
copyleft · top 5,000 on PyPI
pylevComputes the Levenshtein distance between two…
permissive · top 5,000 on PyPI
polylevenPolyleven computes Levenshtein distance between…
unclear · top 5,000 on PyPI
cyseqcyseq provides a Cython-optimized…
permissive · top 15,000 on PyPI
pylcsComputes longest common subsequence, longest…
permissive · top 15,000 on PyPI
dtaidistanceComputes distance measures between time series…
permissive · top 15,000 on PyPI
suffix-treesImplements suffix trees and generalized suffix…
permissive · top 15,000 on PyPI