Skip to main content

Yet another bloomfilter implementation in Python

Project description

bloomfilter-py

codecov

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


Download files

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

Source Distribution

bloomfilter-py-0.0.5.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

bloomfilter_py-0.0.5-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file bloomfilter-py-0.0.5.tar.gz.

File metadata

  • Download URL: bloomfilter-py-0.0.5.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1

File hashes

Hashes for bloomfilter-py-0.0.5.tar.gz
Algorithm Hash digest
SHA256 beabd0b74a8aeb4aa7b670e5b931209dbd5d378eb01492294b030aabb2999926
MD5 d016f27f597823f51f53e9decc89ef1c
BLAKE2b-256 d2378e10e33ba1bf1045d1b21e1cb7c3b95b3d7cfe81994ee19666df53d50e0f

See more details on using hashes here.

File details

Details for the file bloomfilter_py-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: bloomfilter_py-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1

File hashes

Hashes for bloomfilter_py-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9adaf3365c4686f2a7f094c64fa95bce38661b99326987791dde0f732fd27019
MD5 c6c2d8e8d36676d98b03b03e1b1364e6
BLAKE2b-256 81a1867d52beae28bee71a6cffb50f8854e4a3619db71a5c9941ca09cf758581

See more details on using hashes here.

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