Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Pure Python Bloom Filter module

Project description

A pure python bloom filter (low storage requirement, probabilistic set datastructure) is provided. It is known to work on CPython 2.x, CPython 3.x, Pypy and Jython.

Includes mmap, in-memory and disk-seek backends.

The user specifies the desired maximum number of elements and the desired maximum false positive probability, and the module calculates the rest.


from bloom_filter import BloomFilter

# instantiate BloomFilter with custom settings,
# max_elements is how many elements you expect the filter to hold.
# error_rate defines accuracy; You can use defaults with
# `BloomFilter()` without any arguments. Following example
# is same as defaults:
bloom = BloomFilter(max_elements=10000, error_rate=0.1)

# Test whether the bloom-filter has seen a key:
assert "test-key" in bloom is False

# Mark the key as seen

# Now check again
assert "test-key" in bloom is True

Project details

Download files

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

Files for bloom-filter, version 1.3
Filename, size File type Python version Upload date Hashes
Filename, size bloom_filter-1.3-py3-none-any.whl (8.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size bloom_filter-1.3.tar.gz (6.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page