Yet another bloomfilter implementation in Python
Project description
bloomfilter-py
Overview
Yet another Bloomfilter implementation in Python, compatible with Java's Guava library.
I was looking for a Python library which is capable of reading what Bloomfilter of Java's Guava library serializes and is also able to output byte array which is recognizable by Java. But unfortunately failed. Hence I developed this library by borrowing how Guava implements Bloomfilter serialization/deserialization a lot to deal with Bloomfilters on both Python and Java sides.
As for Bloomfilter usage in Java world, please refer to this post.
Here's a brief introduction to Bloomfilter.
Requirements
- Python 3.7+
This library is not tested under Python 3.6 and lower versions.
Install
pip install bloomfilter-py
Usage Examples
Basic Usage
>>> from bloomfilter import BloomFilter
>>> bloom_filter = BloomFilter(expected_insertions=500, err_rate=0.01)
>>> for i in range(100):
... bloom_filter.put(i)
...
>>> 1 in bloom_filter
True
>>> 100 in bloom_filter
False
>>>
Serialize Bloomfilter
>>> dumps = bloom_filter.dumps()
>>> with open("dumps.out", "wb") as f:
... f.write(dumps)
...
>>>
Deserialize Bloomfilter
>>> with open("dumps.out", "rb") as f:
... bf = BloomFilter.loads(f.read())
...
>>> 1 in bf
True
>>> 100 in bf
False
>>>
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
Built Distribution
File details
Details for the file bloomfilter-py-0.1.0.tar.gz
.
File metadata
- Download URL: bloomfilter-py-0.1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0a53e80e236246c655041847652f7098288bc2e7fde21a0c6f587a37ce1b0a8 |
|
MD5 | 21f2570dfcb4e757cfa73400d8665e64 |
|
BLAKE2b-256 | 9341b876e410a43f49cf32c433ab97068e64b139f99c5069f4978a9d11e6b4bf |
File details
Details for the file bloomfilter_py-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: bloomfilter_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b51b0867fcc5c758b184eb4afe712e5b781e95896114a984d80d656cf10d9d7e |
|
MD5 | 6d9554a34ee61711bd0d0092a0954739 |
|
BLAKE2b-256 | c83d9f0ea73032ebab0b7eab005fc7ae02f7d031aa85962944f5ca08f7664164 |