skillfed

bbhash

A Python wrapper for the BBHash Minimal Perfect Hash Function

bbhash v0.6.0 87.7K downloads/30d#13,775 on PyPI19
License unclear AGING released

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 bbhash

uv

uv add bbhash

poetry

poetry add bbhash

Installing 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

minimal perfect hash function64-bit hash lookupbbhash python wrapperhash table with valuesk-mer hashingperfect hash mphfhash function construction
bioinformaticshash-functioncython

More Scientific/Engineering packages