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.2.1"
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.1.tar.gz
(62.6 kB
view hashes)
Built Distributions
Close
Hashes for fastbloom_rs-0.2.1-cp37-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 699110251a3ad5a8a37045332cff07f6f29036d711d07128d9dcc93cf20185f3 |
|
MD5 | f0dbf96908f574c3e06f44f7cac15a45 |
|
BLAKE2b-256 | f7fd3c1955bbe20a02502a4e9d2a690e079833f00db3bab6ff006716ed3e5d77 |
Close
Hashes for fastbloom_rs-0.2.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0aee71cb627ad3b3463879876def83651931df5ad40d8e95b10b658e1045496f |
|
MD5 | 96cc4700039909a0fb2b83ed4da964e8 |
|
BLAKE2b-256 | 18d3b93106e1bba88c1aecad3e66a7d03d0f7b555c3ba8d97767b143e0a593ec |
Close
Hashes for fastbloom_rs-0.2.1-cp37-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e339747b6aaf945fd454103264fea04ad63ee7af4037a554f52852392603a3a7 |
|
MD5 | 9d13b46fe2ec8d03f3718f1c3771d704 |
|
BLAKE2b-256 | c6091f2646b23cf3c6f8c709d815851fc127c90364b8b7c2fae7f1c484ef70fa |
Close
Hashes for fastbloom_rs-0.2.1-cp37-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22103e447d33473ec3b2a605b5de1614500de98e65ba71abdc6ceb4bb36b82e5 |
|
MD5 | d457bd7c1ca6dd125fe88cc2bdf2aef6 |
|
BLAKE2b-256 | 2a72014012fd36934b2334692fff72512a3c19f49e22cff31cabec174475d353 |
Close
Hashes for fastbloom_rs-0.2.1-cp37-abi3-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 392db74f2baee80df97b1dbabb32f875d959155018a54cb99cbe6055364832f5 |
|
MD5 | 0bdb367ba10a299a73cc44c3239e21c8 |
|
BLAKE2b-256 | 535b50ec327051d6b79580ca674e7cdf77349b6ee5eb16e6b6328612b86ee469 |