bbhash
A Python wrapper for the BBHash Minimal Perfect Hash Function
What it is and what it does
pybbhash is a Cython wrapper around the BBHash C++ library for constructing minimal perfect hash functions optimized for 64-bit hash values. It provides two main interfaces: PyMPHF for building and querying a minimal perfect hash function, and BBHashTable for associating arbitrary values with hashes and retrieving them later. The package is designed primarily for bioinformatics workflows involving k-mer hashing, where you need to map large collections of hash values to compact integer identifiers or associated metadata.
The core use case is storing and querying relationships between hashes generated by tools like khmer or sourmash—for example, mapping k-mer hashes to De Bruijn graph node IDs. BBHashTable extends the basic MPHF by supporting lookups on hashes that were not part of the original construction, returning None for missing keys. Both modules support save/load to disk for persistence.
Use it for:
- Map k-mer hashes to De Bruijn graph node identifiers in genome assembly workflows.
- Store and retrieve compact metadata associated with large collections of 64-bit hashes without full hash table overhead.
- Build minimal perfect hash functions for read deduplication or abundance tracking in sequencing pipelines.
- Query pre-built MPHF structures loaded from disk to avoid reconstruction overhead in repeated analyses.
- Associate arbitrary values with hashes in memory-constrained bioinformatics environments where space efficiency matters.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Builds minimal perfect hash functions for 64-bit hashes using BBHash, with optional value-table storage for hash-to-value lookups.
Yes, with conditions. Install if you need minimal perfect hash functions for 64-bit hashes in a bioinformatics or k-mer-heavy workflow and can tolerate Cython compilation. The package is actively maintained and has no known vulnerabilities, but verify the unclear license status before use in proprietary contexts. High install friction and Python >=3.11 requirement may limit adoption in legacy environments.
Install
bbhash on PyPI
pip
pip install bbhashuv
uv add bbhashpoetry
poetry add bbhashInstalling bbhash
Before you install
High install friction due to Cython compilation requirement. Package is aging (292 days since last release) but repository remains active with a recent commit on 2025-10-26. Requires Python >=3.11.
License in practice
License status is unclear—no SPDX identifier or raw license text is available in the package metadata. Verify the actual license before use in proprietary or restricted contexts.
Quickstart
import bbhash
uint_hashes = [10, 20, 50, 80]
mph = bbhash.PyMPHF(uint_hashes, len(uint_hashes), 1, 1.0)
for val in uint_hashes:
print('{} hashes to {}'.format(val, mph.lookup(val)))
Requires Cython compilation during install (high friction). Python >=3.11 required. Depends on numpy.
Verify before relying
- Thread safety of PyMPHF and BBHashTable is noted as needing investigation by the maintainer.
- Whether the package is suitable for production use in bioinformatics pipelines beyond the original spacegraphcats use case.
- Performance characteristics and memory overhead compared to alternative hash table implementations.
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | high — source build required |
| Runtime dependencies | 1 — numpy |
| Maintenance | aging — 292 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 87,699/month — #13,775 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: bbhash-0.6.0.tar.gz
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
mmhash3mmhash3 is a Python wrapper for MurmurHash3,…
permissive · top 15,000 on PyPI
mmh3mmh3 is a Python binding to MurmurHash3, a fast…
permissive · top 1,000 on PyPI
py-multihashEncodes and decodes multihash digests,…
permissive · top 15,000 on PyPI
pyfarmhashProvides Python bindings to Google's FarmHash,…
permissive · top 15,000 on PyPI
xxhashxxhash provides fast non-cryptographic hashing…
permissive · top 1,000 on PyPI
murmurhashProvides fast MurmurHash2 hashing through…
permissive · top 1,000 on PyPI
filehashCalculates and verifies file checksums and…
permissive · top 15,000 on PyPI
dict-hashGenerates consistent hashes for Python…
permissive · top 15,000 on PyPI
cityhashPython wrapper for Google's CityHash and…
permissive · top 15,000 on PyPI
blurhash-pythonEncodes images into BlurHash strings, compact…
permissive · top 15,000 on PyPI