Skip to main content

pybloomfilter3

pybloomfilter3 is a maintained fork of pybloomfiltermmap3 by @prashnts.

The goal of pybloomfilter3 is simple: to provide a fast, simple, scalable, correct library for Bloom filters in Python.

Build Status PyPI PyPI PyPI

Why pybloomfilter3?

There are a couple reasons to use this module:

  • It natively uses mmapped files.
  • It is fast (see benchmarks).
  • It natively does the set things you want a Bloom filter to do.

Quickstart

After you install, the interface to use is a cross between a file interface and an ste interface. As an example:

    >>> import pybloomfilter
    >>> fruit = pybloomfilter.BloomFilter(100000, 0.1, '/tmp/words.bloom')
    >>> fruit.update(('apple', 'pear', 'orange', 'apple'))
    >>> len(fruit)
    3
    >>> 'mike' in fruit
    False
    >>> 'apple' in fruit
    True

To create an in-memory filter, simply omit the file location:

    >>> fruit = pybloomfilter.BloomFilter(10000, 0.1)
    >>> fruit.add('apple')
    >>> 'apple' in fruit
    True

These in-memory filters can be pickled and reloaded:

    >>> import pickle
    >>> pickled_fruit = pickle.dumps(fruit)
    >>> unpickled_fruit = pickle.loads(pickled_fruit)
    >>> 'apple' in unpickled_fruit
    True

Caveat: it is currently not possible to persist this filter later as an mmap file.

Docs

Current docs are available at pybloomfiltermmap3.rtfd.io.

Install

To install:

pip install pybloomfilter3

and you should be set.

History and Future

pybloomfiltermmap is an excellent Bloom filter implementation for Python 2 by @axiak and contributors. I, @prashnts, made initial changes to add support for Python 3 sometime in 2016 as the current pybloomfiltermmap3 on PyPI. Since then, with the help of contributors, there have been incremental improvements and bug fixes while maintaining the API from versions 0.4.x and below. @cavoq forked pybloomfiltermmap3 in 2025 to continue development and maintenance of the library to ensure it remains compatible with the latest Python versions (pybloomfilter3 on PyPI).

Some new features and changes were first introduced in version 0.5.0. From this point on, the goal is to reach stability, as well as add a few more APIs to expand upon the use cases. While we can't guarantee that we won't change the current interface, the transition from versions 0.4.x and below should be quick one liners. Please open an issue if we broke your build!

Suggestions, bug reports, and / or patches are welcome!

Contributions and development

When contributing, you should set up an appropriate Python 3 environment and install the dependencies listed in requirements-dev.txt. Package installation depends on a generated pybloomfilter.c file, which requires Cython module to be in your current environment.

Environment setup

# Creates a virtual env called "env"
python -m venv env

# Activates the created virtual env
source env/bin/activate

Dependencies

python -m pip install --upgrade pip
pip install cython

Build

python -m build

Test

python -m unittest discover -s tests -p "*.py"

Publish

python -m pip install --upgrade twine
python -m twine upload dist/*.tar.gz

Maintainers

License

See the LICENSE file. It's under the MIT License.

Metadata

Release files for pybloomfilter3 0.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybloomfilter3 0.7.3
File Size Uploaded
pybloomfilter3-0.7.3.tar.gz 143.5 kB Details

Release files / pybloomfilter3-0.7.3.tar.gz

Download URL pybloomfilter3-0.7.3.tar.gz
Size 143.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8dda9ea655382da62348fee2732d1a1a5f9c848e173dc57430e9f196b068297e
BLAKE2b-256 checksum
How to use checksums
70536e8eb939a64d9c741717c8bdc5c66dd4bd6627e515b9bceb964c63aea1e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.7.3 This release

1 release file

0.7.1

1 release file

0.7.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page