Welcome to Python BloomFilter’s documentation!

If you are here, you probably don’t need to be reminded about the nature of a Bloom filter. If you need to learn more, just visit the wikipedia page to learn more. This module implements a Bloom filter in python that’s fast and uses mmap files for better scalability. Did I mention that it’s fast?

Here’s a quick example:

from pybloomfilter import BloomFilter

bf = BloomFilter(10000000, 0.01, 'filter.bloom')

with open("/usr/share/dict/words") as f:
    for word in f:

print 'apple' in bf
#outputs True

That wasn’t so hard, was it? Now, there are a lot of other things we can do. For instance, let’s say we want to create a similar filter with just a few pieces of fruit:

fruitbf = bf.copy_template("fruit.bloom")
fruitbf.update(("apple", "banana", "orange", "pear"))
print fruitbf.to_base64()


All of the reference information is available below:

Why pybloomfilter

As I already mentioned, there are a couple reasons to use this module:

  • It natively uses mmaped files.
  • It natively does the set things you want a Bloom filter to do.
  • It is Fast (see Benchmarks).


Simple load and add speed

I have a simple benchmark in test/speedtest.py which compares this module to the good pybloom module:

(pybloom module)
pybloom load took 0.76436 s/run
pybloom tests took 0.16205 s/run
Errors: 0.25% positive 0.00% negative

(this module)
pybloomfilter load took 0.05423 s/run
pybloomfilter tests took 0.00659 s/run
Errors: 0.26% positive 0.00% negative

In this test we just looked at adding words from a dictionary file, then testing to see if each word of another file was in the dictionary.


Since this package natively uses mmap files, no serialization is needed. Therefore, if you have to do a lot of moving between disks etc, this module is an obvious win.


You do not need Cython to install from sources, since I keep a cached version of the c output in the source distribution. Thus, to install you should only need to run:

$ sudo pip install pybloomfiltermmap

You can also download the latest tar file from the github tags. Once you download it, you should only have to run:

$ sudo python setup.py install

to build and install the module.


To develop you will need Cython. The setup.py script should automatically build from Cython source if the Cython module is available.