Skip to content

Instantly share code, notes, and snippets.

View scriptking's full-sized avatar

Manas Sahoo scriptking

  • India
View GitHub Profile
@scriptking
scriptking / bloom.py
Created April 13, 2017 08:41 — forked from josephkern/bloom.py
A Simple Bloom Filter in Python
#!/usr/bin/env python
"""A simple Bloom Filter implementation
Calculating optimal filter size:
Where:
m is: self.bitcount (how many bits in self.filter)
n is: the number of expected values added to self.filter
k is: the number of hashes being produced
(1 - math.exp(-float(k * n) / m)) ** k
http://en.wikipedia.org/wiki/Bloom_filter
"""