GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - remram44/python-bloom-filter: Bloom filter for Python

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

128 Commits
128 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
bin
bin
 
 
src/bloom_filter2
src/bloom_filter2
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
AUTHORS.md
AUTHORS.md
 
 
Makefile
Makefile
 
 
README.rst
README.rst
 
 
setup.py
setup.py
 
 

Repository files navigation

bloom-filter

A pure python bloom filter (low storage requirement, probabilistic set datastructure) is provided. It is known to work on CPython 3.x, Pypy, and Jython.

Includes mmap, in-memory and disk-seek backends.

This project builds on drs-bloom-filter and bloom_filter_mod. Credits and links can be found in AUTHORS.md.

Usage

The user specifies the desired maximum number of elements and the desired maximum false positive probability, and the module calculates the rest.

from bloom_filter2 import BloomFilter

# instantiate BloomFilter with custom settings,
# max_elements is how many elements you expect the filter to hold.
# error_rate defines accuracy; You can use defaults with
# `BloomFilter()` without any arguments. Following example
# is same as defaults:
bloom = BloomFilter(max_elements=10000, error_rate=0.1)

# Test whether the bloom-filter has seen a key:
assert "test-key" not in bloom

# Mark the key as seen
bloom.add("test-key")

# Now check again
assert "test-key" in bloom

Bloom filter are pretty space efficient : only 200MB of memory usage for storing 100M elements with an error of 1%, compared to the 7GB required for set(range(10**8))

It still can be pretty useful to save/load to files with the mmap implementation, for example to avoid rebuilding the bloom filter. The mmap functionality also save some memory depending on system settings.

bloom = BloomFilter(max_elements=10**8, error_rate=0.01, filename=('/tmp/bloom.bin', -1))

About

Bloom filter for Python

pypi.org/project/bloom-filter2/

Topics

bloom-filterdata-structureshacktoberfest

Resources

Readme
Activity

Stars

44 stars

Watchers

1 watching

Forks

6 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.