简体   繁体   中英

Change python2 library pybloomfilter to python3

I want to use pybloomfilter package: https://github.com/axiak/pybloomfiltermmap , I managed to install it under python3, but it seems the saved file does not have the original information (under python2, this won't happen), I looked into source code and it seems there is nothing specific to python2, so I am totally lost on how to make this library compatible with python3.

EDIT1: by "not have the original information", I mean, when I add some string into the filter, then I end the program, the next time, I use open to load the filter, the filter is clear, it does not remember the added strings.

pybloomfiltermmap3 is a Python 3 fork of pybloomfiltermmap by Michael Axiak (@axiak).

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

Install:

Please have Cython installed. Please note that this version is for Python 3. In case you are using Python 2, please see https://github.com/axiak/pybloomfiltermmap .

To install:

$ pip install cython 
$ pip install pybloomfiltermmap3

to build and install the module.

And there is a instance method to sync the file:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM