No project description provided
Project description
rBloom
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(1000):
filter.add(i*i)
for i in range(1000**2):
if i in filter:
print(i, end=" ")
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
Hashes for rbloom-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef93063e692883fa6a15239866c900af837af9d233c09dddfec57180646ea9ae |
|
MD5 | b45cbce02fa7032e80be83901e42893a |
|
BLAKE2b-256 | d04214992845dd7ac79bc28db332d7f5e61a79b03f60d22c698d4a3d8c7ae6ab |