A Bloom filter implementation in Python 3
Project description
bloomfilter3
Python bloom-filter library with a focus on ease of use and high performance.
Motivation
This library was heavily inspired from the excellent bloom-filter2 library, however I decided to make some changes that enhanced functionality and ease of use.
Unfortunatly these changes makes the library non-backwards compatible, hence bloomfilter3 was born.
Credits and links can be found in AUTHORS.md.
Changes from bloom-filter2:
- mmap only and by default
- bloom filter parameters are stored WITH the bloom filter itself on disk, no need to keep track of parameters (max_elements, error_rate) seperatly
- Simpler persistence
Using
from bloom_filter3 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=10_000,
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
Contributing
- Please review CODE_OF_CONDUCT.md
- Please make sure you do
make tests
andmake lint
before submitting a PR - Please make sure you add tests for any new functionality
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bloomfilter3-1.0.1.tar.gz
(10.9 kB
view hashes)
Built Distribution
Close
Hashes for bloomfilter3-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f19d9babe56bf07a4e404ce89767610385045862db4047ae82b3f238bdf1428 |
|
MD5 | 2244781a3ecc1fbdeacea447f381a4dc |
|
BLAKE2b-256 | b49d727edb2bb97bcb66ca54ff3aada1950159194d6fb3f96f55ca7833d6051b |