跳转到主要内容

纯Python Bloom Filter模块

项目描述

提供了一个纯Python Bloom Filter(低存储需求,概率集合数据结构)。已知它在CPython 3.x、Pypy和Jython上工作。

包括mmap、内存和磁盘查找后端。

本项目基于drs-bloom-filterbloom_filter_mod构建。详情和链接可以在AUTHORS.md中找到。

使用方法

用户指定所需的元素最大数量和期望的最大误报概率,模块将计算其余部分。

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-filter2-2.0.0-1.tar.gz (6.6 kB 查看哈希)

构建分发

bloom_filter2-2.0.0-py3-none-any.whl (6.8 kB 查看哈希值)

上传时间: Python 3

由以下支持