Skip to main content

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

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

This project builds on drs-bloom-filter and bloom_filter_mod. Credits and links can be found in AUTHORS.md.

Usage

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

from bloom_filter2 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" not in bloom

# Mark the key as seen
bloom.add("test-key")

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

Release files for bloom-filter2 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bloom-filter2 2.0.0
File Size Uploaded
bloom-filter2-2.0.0-1.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bloom-filter2 2.0.0
File Interpreter ABI Platform
bloom_filter2-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 kB

Release files / bloom-filter2-2.0.0-1.tar.gz

Download URL bloom-filter2-2.0.0-1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
310e5d3aa15be6e3d2285a7111f60cc44a1f500159412f2c72d155f43037cefd
BLAKE2b-256 checksum
How to use checksums
2b5d8de4a849ebe212217e6d8f4798a6918d4035e741c44730da81272f170b47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

Release files / bloom_filter2-2.0.0-py3-none-any.whl

Download URL bloom_filter2-2.0.0-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9d3a3a44ae917ab9c13f71b542ac88b863f0cf4e64afbca48777cf0d5310c93
BLAKE2b-256 checksum
How to use checksums
52d7871408c1c1230af64eb00e2064f6e8a065ae652f17f010b3f4f102e5fbac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page