Skip to main content

fastbktree :deciduous_tree:

A Rust implementation of BK-trees for fast fuzzy string matching in Python.

Installation

uv add fastbktree
# pip install fastbktree

Quickstart

from fastbktree import BKTree

# Create a BK-tree from a list of strings
tree = BKTree(["hello", "help", "hell", "shell", "helper"])
results = tree.search("helo", max_distance=2)

Reference

BKTree(iterable)

Creates a new BK-tree from an iterable of strings.

tree = BKTree(["word1", "word2", "word3"])

tree.search(query: str, max_distance: int) -> List[Tuple[str, int]]

Searches for strings similar to query within max_distance Levenshtein distance. Returns a list of (string, distance) tuples.

results = tree.search("query", max_distance=2)
# [('hello', 1), ('help', 1), ('shell', 2), ('hell', 1)]

levenshtein_distance(a: str, b: str) -> int

Pure Rust implementation of Levenshtein distance between two strings.

from fastbktree import levenshtein_distance

distance = levenshtein_distance("kitten", "sitting")  # 3

License

MIT

Metadata

Release files for fastbktree 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastbktree 0.1.1
File Size Uploaded
fastbktree-0.1.1.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastbktree 0.1.1
File Interpreter ABI Platform
fastbktree-0.1.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details

Total release size: 239.5 kB

Release files / fastbktree-0.1.1.tar.gz

Download URL fastbktree-0.1.1.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c088e117382c1f6897576fb11b2cba53f9ccab0e59ad22ef79a08e0b411259dd
BLAKE2b-256 checksum
How to use checksums
867193bef8579334b20f9bfbe2d58d0220ca764267b5678bf12e25b1702878b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.7

Release files / fastbktree-0.1.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL fastbktree-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Size 233.0 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2397819729c85fa2eb6720ef824221e6c9cac98f58bbdf0de10fadabaec5c673
BLAKE2b-256 checksum
How to use checksums
35b0eba046cd1af931b1e6d2b6182f6e5ebc4942ba970bc85d0914b41b9947e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page