rBloom

1.5.4 · active · verified Thu Apr 16

rBloom is a highly optimized Bloom filter library for Python, implemented in Rust. It provides a fast, simple, and lightweight probabilistic data structure that closely mimics the Python built-in `set` API. Currently at version 1.5.4, it's designed for high-performance set membership testing with low memory footprint, and it sees regular updates, often driven by underlying PyO3 version enhancements.

Common errors

Warnings

Install

Imports

Quickstart

Initializes a Bloom filter with a specified capacity and false positive rate, demonstrates adding single and multiple elements, checking for membership, and performing a set-like union operation.

from rbloom import Bloom

# Initialize a Bloom filter for 200 items with a 1% false positive rate
bf = Bloom(200, 0.01)

# Add items
bf.add("hello")
bf.add("world")

# Check for membership
print(f"'hello' in bf: {"hello" in bf}")
print(f"'python' in bf: {"python" in bf}")

# Update with multiple items
bf.update(["rust", "fast"])

# Set-like operations
other_bf = Bloom(200, 0.01)
other_bf.add("rust")
union_bf = bf | other_bf # Union of filters
print(f"'rust' in union_bf after union: {"rust" in union_bf}")

view raw JSON →