CFFI bindings to the CMPH library
These bindings provide python with the ability to create and use Minimal Perfect Hashes via the CMPH library.
Installation
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+https://github.com/URXtech/cmph-cffi'
Usage
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
mph('Test')
Warning
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:
mph.save(out_file)
Loading a pre-existing MPH
with open('/tmp/out.mph') as in_file:
cmph.load_hash(in_file)
Authors
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.
Contribute
Please see CONTRIBUTING.
Licence
Please see LICENSE.