Skip to main content

No project description provided

Project description

rBloom

PyPI GitHub tag (latest SemVer)

Ultralightweight, blazing fast, minimalistic bloom filter library for Python, implemented in Rust.

Usage

This library defines only one class, the signature of which should be thought of as:

class Bloom:

    def __init__(self, size_in_bits):
        ...

    def __contains__(self, object):
        ...

    def add(self, object):
        ...

See examples.

The size in bits is equal to the theoretical maximum amount of objects that could be contained in the filter. However, the filter should ideally be significantly larger than this to reduce the likelihood of birthday collisions, which in practice result in a false positive True returned by the __contains__ method. To decide on an ideal size, calculate size_in_bits by dividing the maximum number of expected items by the maximum acceptable likelihood of a false positive (e.g. 200 items / 0.01 likelihood = 20000 bits).

Building

Use maturin to build this library. As of the time of writing, this can be performed with:

$ pip install maturin
$ maturin build --release

This will result in the creation of a wheel, which can be found in target/wheels.

Examples

Most primitive example:

from rbloom import Bloom

filter = Bloom(200)

assert "hello" not in filter

filter.add("hello")

assert "hello" in filter

Print the first 1000 squares as well as around 0.001 = 0.1% of the numbers in between:

from rbloom import Bloom

filter = Bloom(int(1000 / 0.001))

for i in range(1, 1001):
    filter.add(i*i)

for i in range(1, 1000**2 + 1):
    if i in filter:
        print(i, end=" ")

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

rbloom-0.1.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

rbloom-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl (198.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

File details

Details for the file rbloom-0.1.2.tar.gz.

File metadata

  • Download URL: rbloom-0.1.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.14.8

File hashes

Hashes for rbloom-0.1.2.tar.gz
Algorithm Hash digest
SHA256 78aa84a482357a62f7db848ba4025ebed823b156e6b03a71731826057044c41a
MD5 264b0b99b225eccb7a05926153d6b845
BLAKE2b-256 722626e129315865e0d4035b172b1253b1647d83c720ecedc1db2d173306626d

See more details on using hashes here.

File details

Details for the file rbloom-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rbloom-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f25dafc40d9cc22acdf64f7eeef446f31fef13f5fb9a66dfc3b8f8fe32a4393f
MD5 25b532eb9f6296e8d7b6f975b500ad85
BLAKE2b-256 9b7f692fb2e1ec31ff7c118516741597a4ca796a7daa13e9e7086d3e1790a6da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page