Registry / search / pybktree

pybktree

JSON →
library1.1pypypi✓ verified 86d ago

pybktree is a Python implementation of BK-trees (Burkhard-Keller trees), an efficient data structure for performing nearest-neighbor search in metric spaces. It supports fast querying of items within a specified edit distance, commonly used for fuzzy string matching. The current version is 1.1, with no recent activity since 2015.

pip install pybktree
INSTALL
IMPORT
SIG · PYBKTREE
P
pybktree
searchpythonv1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BKTree
from pybktree import BKTree

Create a BKTree with a distance function and items. Query with a target and maximum distance.

from pybktree import BKTree def hamming_distance(a, b): return sum(c1 != c2 for c1, c2 in zip(a, b)) tree = BKTree(hamming_distance, ['abc', 'abd', 'xyz']) results = tree.find('abc', 1) print(results) # [(0, 'abc'), (1, 'abd')]
Debug
Known issues
gotchaThe distance function must be a metric (satisfy triangle inequality) for BK-tree to work correctly. Non-metric functions may yield incorrect results.
fix
Ensure your distance function is a proper metric (e.g., Levenshtein, Hamming, Euclidean).
affects: all
deprecatedThe library hasn't been updated since 2015 and has no official support. Its use in new projects is discouraged in favor of more maintained alternatives.
fix
Consider using a more modern library like `textdistance` or `rapidfuzz` for fuzzy matching.
affects: 1.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pybktree'
The library is not installed.
fix
Run: pip install pybktree
TypeError: distance must be a callable
The first argument to BKTree constructor is not a function.
fix
Pass a callable distance function, e.g., BKTree(lambda a,b: abs(a-b), items)
Upgrade
Version history
1.1latest on PyPI · released Aug 22, 2017
Audit
Dependencies

No dependency data recorded yet.

Agent activity
40 hits · last 30 days
node
36
Resources
pybktree — pip install pybktree · libregistry