Skip to content

GregBowyer/cmph-cffi

Repository files navigation

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.

About

Python bindings to the CMPH library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published