Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

CFFI enabled bindings to the CMPH library forcreating and using minimal perfect hashes

Project Description

These bindings provide python with the ability to create and use Minimal Perfect Hashes via the CMPH library.


Should be as simple as

$ pip install cmph-cffi

Development version

The latest development version can be installed directly from GitHub:

$ pip install --upgrade 'git+'


Creating a new MPH

import cmph
with open('/usr/share/dict/words', 'w') as keys:
    mph = cmph.generate_hash(keys)

Getting keys out of an MPH



Be aware that whilst MPH’s are awesome, they typically cannot distinguish between keys they are built on and unseen keys. Concretely this means that feeding in keys that are not in the original key set will have undefined results

Saving the MPH

with open('/tmp/out.mph', 'w') as out_file:

Loading a pre-existing MPH

with open('/tmp/out.mph') as in_file:


Greg Bowyer (@GregBowyer) and Venkatesh Sharma (@Venkateshks) created these bindings and these fine people did all the hard implementation work in CMPH.

Reporting bugs

Please see BUG_REPORTS.




Please see LICENSE.

Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
cmph-cffi-0.3.0.tar.gz (82.7 kB) Copy SHA256 Checksum SHA256 Source Mar 25, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting