moolb

Bloom filter for python3 with pluggable hasher backend
git clone git://git.defalsify.org/python-moolb.git
Log | Files | Refs | README | LICENSE

commit 741df7292773cd5fd82630f33cb7a41606e6a4c0
parent 49f1ede554567ec1ad9ecee8cacbed2ed9040715
Author: nolash <dev@holbrook.no>
Date:   Fri, 30 Oct 2020 10:59:35 +0100

Add dump, remove numpy

Diffstat:
MCHANGELOG | 3+++
Mmoolb/moolb.py | 10++++++----
Msetup.py | 5+----
3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,3 +1,6 @@ +- 0.0.3 + * Remove numpy dependency + * Add dump method - 0.0.2 * Add numpy to deps - 0.0.1 diff --git a/moolb/moolb.py b/moolb/moolb.py @@ -2,14 +2,12 @@ import hashlib import logging import math -import numpy - logging.basicConfig(level=logging.DEBUG) logg = logging.getLogger() - # m = ceil((n * log(p)) / log(1 / pow(2, log(2)))); + class Bloom: def __init__(self, bits, rounds, hasher=None): @@ -18,7 +16,7 @@ class Bloom: if self.bytes * 8 != self.bits: raise ValueError('Need byte boundary bit value') self.rounds = rounds - self.filter = numpy.zeros(self.bytes, dtype=numpy.uint8) + self.filter = [0] * self.bytes if hasher == None: logg.info('using default hasher (SHA256)') hasher = self.__hash @@ -57,6 +55,10 @@ class Bloom: return True + def dump(self): + return self.filter + + def __hash(self, b, s): logg.debug('hashing {} {}'.format(b.hex(), s.hex())) h = hashlib.sha256() diff --git a/setup.py b/setup.py @@ -6,16 +6,13 @@ f.close() setup( name='moolb', - version='0.0.2', + version='0.0.3', description='Simple bloom filter with pluggable hash backend', author='Louis Holbrook', author_email='dev@holbrook.no', license='GPL3', long_description=long_description, long_description_content_type='text/markdown', - install_requires=[ - 'numpy>=1.19.0', - ], packages=[ 'moolb', ],