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
The latest development version can be installed directly from GitHub:
$ pip install --upgrade 'git+https://github.com/GregBowyer/cmph-cffi'
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)
Greg Bowyer (@GregBowyer) created these bindings and these fine people did all the hard implementation work in CMPH.
Please see BUG_REPORTS.
Please see CONTRIBUTING.
Please see LICENSE.