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.6.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: bloomfilter-py-0.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 f24331109fe0399cb5b0d12bdd1bb4d102e66e12077f62ee429e14303361d1b3
MD5 c080fe7d06cfa06beff5a837cc3ae87f
BLAKE2b-256 f5f5134fe75c8cd26e86bcaa64c83953b7809049e48d88665d54c969d1f771ed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bloomfilter_py-0.0.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1c24a1615b445b9a14c10fdb9e7e3e1deb48a97ec0e1378f8df13218ca97679e
MD5 00d5408f7754c3c7a05a18add759fd68
BLAKE2b-256 c1f76e835140a5d9da6807eaf58afdfc9a330247e51b8c528ef7f170ac0040ed

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