Registry / database / pybloom-live

pybloom-live

JSON →
library4.0.0pypypi✓ verified 27d ago

pybloom-live is a Python library providing an efficient implementation of the Bloom filter probabilistic data structure. It also offers a Scalable Bloom Filter, which can dynamically grow its capacity. Currently at version 4.0.0, it is a fork of the original `pybloom` project, with improvements like a consistent tightening ratio. It aims to provide fast, space-efficient membership testing for large datasets where a small probability of false positives is acceptable.

pip install pybloom-live
INSTALL
IMPORT
SIG · PYBLOOM-LIVE
P
pybloom-live
databasepythonv4.0.0
Install
3.2s avg
Import
10ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v4.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.010s · 21.4MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 3.2s · import 0.010s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BloomFilter
✓ from pybloom_live import BloomFilter
ScalableBloomFilter
✓ from pybloom_live import ScalableBloomFilter

This example demonstrates how to initialize a basic `BloomFilter`, add elements, and check for their probable membership. You define the expected capacity and acceptable error rate during initialization.

from pybloom_live import BloomFilter # Initialize a Bloom filter with a capacity of 1000 elements # and an acceptable false positive rate of 0.01 (1%) bloom = BloomFilter(capacity=1000, error_rate=0.01) # Add elements bloom.add("apple") bloom.add("banana") bloom.add("orange") # Check for membership print(f"Is 'apple' in the filter? {'apple' in bloom}") # Expected: True print(f"Is 'grape' in the filter? {'grape' in bloom}") # Expected: False # Note: Due to the probabilistic nature, 'grape' *could* theoretically # return True with a small probability (false positive), but never False # if it was actually added.
Debug
Known issues
breakingVersion 3.0.0 dropped support for Python 2.6. Users on older Python 2.x versions might need to use a prior version of pybloom-live or migrate their Python environment.
fix
Upgrade to Python 2.7+ or Python 3.x; or pin `pybloom-live<3.0.0` if Python 2.6 is unavoidable.
affects: <3.0.0
gotchaBloom filters are probabilistic data structures that can produce 'false positives'. This means they might indicate an element is present when it's not, but they will never produce 'false negatives' (they won't say an element is absent if it was actually added).
fix
Understand the implications of false positives for your application. If zero false positives are required, a different data structure (e.g., a hash set) is necessary, often at the cost of higher memory usage.
affects: All
gotchaThe `BloomFilter` (non-scalable) requires you to pre-define an estimated `capacity` and `error_rate`. If the actual number of elements significantly exceeds the `capacity`, the false positive rate will increase drastically beyond the specified `error_rate`.
fix
Accurately estimate your maximum set size for `BloomFilter`. If the set size is unpredictable or grows over time, consider using `ScalableBloomFilter` which dynamically adjusts its size.
affects: All
gotcha`pybloom-live` is a fork of the original `pybloom` library. While `pybloom-live` is actively maintained and has improvements, ensure you are importing from `pybloom_live` (e.g., `from pybloom_live import BloomFilter`) to use the correct version and features. Accidental imports from an older `pybloom` might lead to unexpected behavior or missing features.
fix
Verify your import statements use `from pybloom_live import ...`. Check your `pip freeze` output to confirm `pybloom-live` is installed and not an older `pybloom` library.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pybloom_live'
The 'pybloom-live' package is not installed in the Python environment.
fix
Install the package using pip: 'pip install pybloom-live'.
ImportError: cannot import name 'BloomFilter' from 'pybloom_live'
The 'pybloom-live' package is installed, but the 'bitarray' dependency is missing.
fix
Install the 'bitarray' package using pip: 'pip install bitarray'.
ValueError: Invalid error_rate
An invalid 'error_rate' parameter was provided when initializing the BloomFilter; it must be between 0 and 1.
fix
Ensure the 'error_rate' parameter is set to a value between 0 and 1 when creating a BloomFilter instance.
IndexError: BloomFilter is at capacity
Attempting to add more items to the BloomFilter than its defined capacity allows.
fix
Increase the 'capacity' parameter when initializing the BloomFilter to accommodate more items.
from pybloom import BloomFilter
Users attempting to import `BloomFilter` or `ScalableBloomFilter` from the original `pybloom` package instead of the forked `pybloom-live` library.
fix
Use the correct import path for the `pybloom-live` library: `from pybloom_live import BloomFilter` or `from pybloom_live import ScalableBloomFilter`
Upgrade
Version history
4.0.0latest on PyPI · released Oct 15, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
Resources
pybloom-live — pip install pybloom-live · libregistry