https://github.com/masroore/pybloomer
Fast Python Bloom Filter using memory-mapped files
https://github.com/masroore/pybloomer
bloom-filter bloom-filters bloomfilter bloomfilter-python python python3
Last synced: 7 months ago
JSON representation
Fast Python Bloom Filter using memory-mapped files
- Host: GitHub
- URL: https://github.com/masroore/pybloomer
- Owner: masroore
- License: mit
- Created: 2023-04-28T06:04:03.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-04-28T09:45:06.000Z (over 2 years ago)
- Last Synced: 2025-03-01T21:03:31.679Z (7 months ago)
- Topics: bloom-filter, bloom-filters, bloomfilter, bloomfilter-python, python, python3
- Language: C
- Homepage: https://pybloomer.readthedocs.io
- Size: 2.19 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- Changelog: CHANGELOG
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
# pybloomer
[pybloomer](https://github.com/masroore/pybloomer) is a Python 3 compatible fork
of [pybloomfiltermmap](https://github.com/axiak/pybloomfiltermmap) by [@axiak](https://github.com/axiak).The goal of `pybloomer` is simple: to provide a fast, simple, scalable, correct library for Bloom filters in Python.
[](https://pybloomer.readthedocs.io/en/latest/?badge=latest)
[](https://pypi.python.org/pypi/pybloomer)
[](https://pypi.python.org/pypi/pybloomer)
[](https://pypi.python.org/pypi/pybloomer)## Why pybloomer?
This module implements a Bloom filter in Cython (ANSI C) that's fast and uses memory-mapped files for better
scalability.There are a couple reasons to use this module:
* It natively uses [mmaped files](http://en.wikipedia.org/wiki/Mmap).
* It is fast (see [benchmarks](http://axiak.github.io/pybloomfiltermmap/#benchmarks)).
* It natively does the set things you want a Bloom filter to do.## Installation
To install `pybloomer`, use the Python 3 version of pip:
```shell
$ pip install pybloomer
```## Quickstart
Here’s a quick example:
```python
>>> import pybloomer
>>> fruits = pybloomer.BloomFilter(capacity=10000000, error_rate=0.01, filename='/tmp/fruits.bloom')
>>> fruits.update(('apple', 'pear', 'orange', 'apple'))
>>> len(fruits)
3
>>> 'mike' in fruits
False
>>> 'orange' in fruits
True
```To create an in-memory filter, simply omit the file location:
```python
cake_ingredients = pybloomer.BloomFilter(capacity=1000, error_rate=0.1)
```*Caveat*: in-memory filters cannot be persisted to disk.
## Documentation
Current docs are available at [pybloomer.rtfd.io](https://pybloomer.readthedocs.io/en/latest).
## Contributions and development
Suggestions, bug reports, and / or patches are welcome!
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 `pybloomer.c` file, which requires Cython module to be in your current
environment.## Maintainers
* [Dr. Masroor Ehsan](https://github.com/masroore)
## License
See the LICENSE file. It's under the MIT License.