Skip to main content

python implementation of bloom filter

Project description

bloom filter

tests
python implementation of bloom filter

What is bloom filter? https://en.wikipedia.org/wiki/Bloom_filter

installation

$ pip install easy-bloom-filter

usage

Simple example

from easy_bloom_filter import BloomFilter, Response

bf = BloomFilter(init_size=2001, func_count=3)

bf.add_element("first")
bf.add_element("second")
bf.add_element({"num": "3"})

print(bf.query("4")     == Response.NO)     # True (not added to filter)
print(bf.query("first") == Response.MAYBE)  # True (maybe added to filter check with the source of truth)

print(bf.false_positive_probability)  # 9.09884490736791e-08
print(bf.actual_size)                 # 2000  (round to multiple of 8 for storing the data on bits)

install dev requirements

$ pip install -r requirements-dev.txt

only tests

$ pytest .

tests with coverage

$ pytest --cov-report=html --cov=py_bloom_filter tests/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easy-bloom-filter-0.1.0.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

easy_bloom_filter-0.1.0-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page