alexeygrigorev / libbloom-python

Fast bloom filters for python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LibBloom-Python

Fast bloom filters implementation with Python bindings

The implementation is based on bloomfilter.js - and it's (almost) a direct translaslation form JavaScript to C.

Example

import pyfvnbloom

bf = pyfvnbloom.create_empty(capacity=1000, error_rate=0.01)
bf.add('ololo')

assert 'ololo' in bf
assert 'lol' not in bf

Building and installing

CMake

To build the binaries, you need to have CMake. If you don't have it:

mkdir cmake && cd cmake
wget https://cmake.org/files/v3.10/cmake-3.10.0-Linux-x86_64.sh
bash cmake-3.10.0-Linux-x86_64.sh --skip-license
export CMAKE_HOME=`pwd`
export PATH=$PATH:$CMAKE_HOME/bin

Bulding it

Build the binaries:

mkdir build && cd build
cmake ..
make

Run some tests:

./test/testrun

If everything is fine, copy them:

cd ..
cp build/bloom/libbloom.so pyfvnbloom/

Now let's test it:

nosetests pytest/bloom_tests.py 

If everything is fine, you can install it:

python setup.py install

Wheel

You can build a wheel and then use it for installing the package instead of building it from the sources

python setup.py sdist bdist_wheel

The result will be in the dist folder:

dist/pyfvnbloom-0.0.1-cp36-cp36m-linux_x86_64.whl

About

Fast bloom filters for python


Languages

Language:Python 48.9%Language:C++ 35.1%Language:CMake 10.0%Language:C 4.0%Language:Shell 1.9%