An open API service indexing awesome lists of open source software.

https://github.com/long-gong/open-bloom-filter-wrapper

Open Bloom Filter (Python Wrapper)
https://github.com/long-gong/open-bloom-filter-wrapper

bloom-filter python python-wrapper

Last synced: 4 months ago
JSON representation

Open Bloom Filter (Python Wrapper)

Awesome Lists containing this project

README

          

# Open Bloom Filter

[Open Bloom Filter](https://github.com/long-gong/open-bloom-filter-wrapper) is a Python wrapper for [C++ Bloom Filter Library](https://github.com/ArashPartow/bloom).

## Install

```bash
make install
```

## Usage

```python
from open_bloom_filter import BloomFilter

if __name__ == "__main__":
entries = 1000000
fpr = 0.01
bf = BloomFilter(entries, fpr)
print(
"size (number of bits): %i, number of hash functions: %i"
% (len(bf), bf.num_hashes())
)

print(f"{entries}")
for i in range(entries):
bf.add(i)
for i in range(entries):
assert i in bf
cf = 0
ct = 0
for i in range(entries, 2 * entries):
if i in bf:
cf += 1
ct += 1
print(f"fpr: {100.0 * cf / ct}%")
```