Skip to main content

hammingbird

The fastest exact Hamming-distance pair-search library on PyPI. Same algorithm as FAISS IndexBinaryMultiHash (Norouzi 2012), with a Rust core, rayon-parallel candidate generation, prefetched popcount verify, and a streaming Index with sub-microsecond query latency.

pip install hammingbird
import numpy as np
from hammingbird import find_pairs_self, Index

# 1M random 256-bit codes
A = np.random.default_rng(0).integers(0, 256, size=(1_000_000, 32), dtype=np.uint8)

# All-pairs near-duplicate search — exact, 100% recall
pairs = find_pairs_self(A, k=2)     # list of (i, j, hamming_dist)

# Streaming index — sub-microsecond per query
idx = Index(d_bytes=32, k=2)
idx.add_batch(A)
hits = idx.query(A[0])              # list of (id, hamming_dist)

Headline numbers (Apple M2 Pro, full reproducibility on GitHub)

Workload hammingbird FAISS IndexBinaryFlat Speedup
n=2,000,000, k=0 (exact dedup) 0.196 s 798.4 s 4073×
n=2,000,000, k=2 (uniform random) 0.312 s 919.3 s 2945×
n=100k Index query latency 0.21 µs median 194 µs median 924× per query
n=100k clustered, k=4 (real-shape) 0.040 s 1.755 s 44×

vs FAISS IndexBinaryMultiHash (same algorithm) at full recall: 3–45× faster. vs usearch / Annoy / FAISS-LSH at clustered n=1M: strict dominance — hammingbird is both faster AND more accurate (those libraries' recall drops below 12% at scale on this workload).

Full head-to-head benchmark report (16 demo presets, every number reproducible): https://github.com/ElVec1o/hammingbird/blob/main/BENCHMARK_RESULTS.md

What it's for

  • Exact dedup at scale (k=0 — the common production workload)
  • Near-duplicate detection on perceptual hashes, SimHash, learned binary embeddings (k ≤ 8 typically)
  • Real-time content moderation — the streaming Index API delivers ~1.6M exact queries/sec per thread, releases the GIL on add_batch
  • Cross-corpus matching — find_pairs_cross(A, B, k) for "dedup incoming batch against blacklist" workloads

What it's not

  • Not a general-purpose ANN library. For approximate-recall workloads at k ≥ 16 or single-query latency budgets < 1 µs with k ≥ 8, FAISS's HNSW family or usearch may be a better fit.
  • Not algorithmically novel. The pigeonhole prefilter is published (Norouzi-Punjani-Fleet 2012). The win is implementation quality.

License

MIT © 2026 Vico Bonfioli.

Source / issues / docs

https://github.com/ElVec1o/hammingbird

Metadata

Release files for hammingbird 0.5.0

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

Source distribution (sdist)

Source distribution for hammingbird 0.5.0
File Size Uploaded Provenance Actions
hammingbird-0.5.0.tar.gz 29.7 kB Without provenance Details for hammingbird-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hammingbird 0.5.0
File Interpreter ABI Platform Actions
hammingbird-0.5.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for hammingbird-0.5.0-cp39-abi3-macosx_11_0_arm64.whl

Total release size: 711.5 kB

Release files / hammingbird-0.5.0.tar.gz

Download URL hammingbird-0.5.0.tar.gz
Size 29.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d0477136eb6fdfc8f6ff251272c404131fa789852eade7d0fbeb18003e681dec
BLAKE2b-256 checksum
How to use checksums
188393c9fe5cc5bf908719d240113745372d74581301e7213430cdee2daf3a94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.13.3

Release files / hammingbird-0.5.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL hammingbird-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
Size 681.8 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f342dd1b3f8a4de41350bb17a6b518cf9a9ecfed39768b45a7937d02233f1e36
BLAKE2b-256 checksum
How to use checksums
e592980b1c6f84554e9f69e4ec8f30c8153620ffd870c2e076c4b1336edbf1c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.13.3

Security for hammingbird 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files No provenance

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