Python bindings to the CMPH library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cmph
tests
.bumpversion.cfg
.gitignore
.travis.yml
AUTHORS.rst
BUG_REPORTS.rst
CMakeLists.txt
CONTRIBUTING.rst
LICENSE
README.rst
check-and-dump-corefiles.sh
extract-backtrace.sh
setup.py
tox.ini

README.rst

CFFI bindings to the CMPH library

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


Latest version released on PyPi Build status Coverage Code Health


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/GregBowyer/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) 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.