A fast bloom filter implemented by Rust for Python and Rust!
Project description
fastbloom
A fast bloom filter implemented by Rust for Python and Rust!
setup
Python
requirements
Python >= 3.7
install
Install the latest fastbloom version with:
pip install fastbloom-rs
Rust
fastbloom-rs = "0.1.3"
Examples
Python
basic usage
from fastbloom_rs import BloomFilter
bloom = BloomFilter(100_000_000, 0.01)
bloom.add_str('hello')
bloom.add_bytes(b'world')
bloom.add_int(9527)
assert bloom.contains('hello')
assert bloom.contains(b'world')
assert bloom.contains(9527)
assert not bloom.contains('hello world')
build bloom filter from bytes or list
from fastbloom_rs import BloomFilter
bloom = BloomFilter(100_000_000, 0.01)
bloom.add_str('hello')
assert bloom.contains('hello')
bloom2 = BloomFilter.from_bytes(bloom.get_bytes(), bloom.hashes())
assert bloom2.contains('hello')
bloom3 = BloomFilter.from_int_array(bloom.get_int_array(), bloom.hashes())
assert bloom3.contains('hello')
Rust
use fastbloom_rs::{BloomFilter, FilterBuilder};
let mut bloom = FilterBuilder::new(100_000_000, 0.01).build_bloom_filter();
bloom.add(b"helloworld");
assert_eq!(bloom.contains(b"helloworld"), true);
assert_eq!(bloom.contains(b"helloworld!"), false);
more examples at docs.rs
benchmark
computer info
CPU | Memory | OS |
---|---|---|
AMD Ryzen 7 5800U with Radeon Graphics | 16G | Windows 10 |
bloom add
Benchmark insert str to bloom filter:
|
|
Additional Statistics:
Lower bound | Estimate | Upper bound | |
---|---|---|---|
Slope | 41.095 ns | 41.146 ns | 41.203 ns |
R² | 0.9959495 | 0.9961648 | 0.9959083 |
Mean | 41.157 ns | 41.207 ns | 41.257 ns |
Std. Dev. | 226.07 ps | 261.59 ps | 294.01 ps |
Median | 41.132 ns | 41.184 ns | 41.247 ns |
MAD | 201.13 ps | 277.13 ps | 335.05 ps |
bloom add one million
Benchmark loop insert (1..1_000_000).map(|n| { n.to_string() })
to bloom filter:
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
fastbloom_rs-0.2.0.tar.gz
(62.4 kB
view hashes)
Built Distributions
Close
Hashes for fastbloom_rs-0.2.0-cp37-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 089c48895115d4a5b25d070f41c86528bf7bf48a69b68d74b5f6b30c7e2812f6 |
|
MD5 | 4b7e5d58f0a54b76a8c55d61d57a3b90 |
|
BLAKE2b-256 | e605a67a82fc2d4cf1835f193dee76b3e1c6028a7337e2c3debf865ae29757d6 |
Close
Hashes for fastbloom_rs-0.2.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69f4659c30e127297fe4d5ee9c65c09c170f39a1b54f6fffe6878e08226d36b9 |
|
MD5 | 77d80ac0fea7185d5dd21affba68c767 |
|
BLAKE2b-256 | 9f7940d17754b57d158d35a77a4ec309cd9af9e83259f546316992275063c57c |
Close
Hashes for fastbloom_rs-0.2.0-cp37-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33fd65edf500a46bd6112c3b98c71e09eed23da87797d66301a9daa1ad43e678 |
|
MD5 | de447c137787f208bab4162e5843e203 |
|
BLAKE2b-256 | 1238338f5a28e7c6ebc973159cd8671344470f2b2c63daf9a8cd0f97156fc43d |
Close
Hashes for fastbloom_rs-0.2.0-cp37-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f33adea6013fee9e0f1f60e344eb2051d4c96018a779d23fc84432b202f47ae |
|
MD5 | a6daf2f176538c040775b991498702da |
|
BLAKE2b-256 | b1b34a224a25236570fd43d9d159c9d39d2f64fedf334724625ffa5c6cfe5051 |
Close
Hashes for fastbloom_rs-0.2.0-cp37-abi3-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7b49cae8740e6b6a1cc7ef95b4802c626b9d0ddb46db44200303167ea0faddf |
|
MD5 | 95cf01f48ed90b89f0d149efd618e100 |
|
BLAKE2b-256 | 40e38c7c27f423cbe58c163bf61fe684e00b627c0e85b01130337e1fda65bd10 |