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 Guava implements Bloomfilter serialization/deserialization steps 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.4.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: bloomfilter-py-0.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 903595258d14df054af5b762e9e512f1e833ff744bb33fddd6d612d7ccdadc45
MD5 23025484d6551809fcc9874d0c93e715
BLAKE2b-256 e8c0e306dc8d1907fbdaf740dfcb0aea0e150d618bde0e518513f9529f088a99

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bloomfilter_py-0.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6a32471f26c5f129e907726a02772b8252ad90f0b2bdc0196adfa6a95c0cbfc6
MD5 9c9a17860eea644f6ba6128e954d6289
BLAKE2b-256 f4a2918a6f4c98575be2e6ee17c51a95503521407fee8846ea034ad091d3f7eb

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