将python2库pybloomfilter更改为python3

时间:2016-03-20 03:07:18

标签: python python-2.7 python-3.x

我想使用pybloomfilter包:https://github.com/axiak/pybloomfiltermmap, 我设法在python3下安装它,但似乎保存的文件没有原始信息(在python2下,这不会发生),我查看源代码,似乎没有什么特定的python2,所以我完全迷失了如何使这个库与python3兼容。

EDIT1: 通过“没有原始信息”,我的意思是,当我在过滤器中添加一些字符串时,我结束程序,下次,我用open打开加载过滤器,过滤器很清楚,它不记得添加了字符串。

1 个答案:

答案 0 :(得分:1)

pybloomfiltermmap3是Michael Axiak(@axiak)的pybloomfiltermmap的Python 3分支。

class pybloomfilter.BloomFilter(capacity : int, error_rate : float[,
                                filename=None : string ][, perm=0755 ])

安装:

请安装Cython。请注意,此版本适用于Python 3.如果您使用的是Python 2,请参阅 https://github.com/axiak/pybloomfiltermmap

安装:

$ pip install cython 
$ pip install pybloomfiltermmap3

构建并安装模块。

还有一种实例方法可以同步文件:

BloomFilter.sync()
  Forces a sync() call on the underlying mmap file object.
  Use this if you are about to copy the file and you want to be Sure (TM)
  you got everything correctly.
相关问题