skillfed

Distance

Utilities for comparing sequences

distance v0.1.3 690.2K downloads/30d#5,332 on PyPI117
Copyleft license UNKNOWN Abandoned released

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 distance

uv

uv add distance

poetry

poetry add distance

Installing 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

Intended Audience :: DevelopersLicense :: OSI Approved :: GNU General Public License (GPL)Natural Language :: EnglishOperating System :: OS IndependentProgramming Language :: CProgramming Language :: PythonProgramming Language :: Python :: 3.3Topic :: Software Development :: Libraries :: Python Modules

Tags

sequence similarity metricslevenshtein distancestring comparisonhamming distancesequence alignmenttext similarityedit distance
string-matchingsequence-algorithmsabandoned

More Python Modules packages