Skip to content

Reloading from a File does not appear to work in python 3 #7

Description

@bscain

The following sample code has been executed on both python 2 and python 3 with the same result

from pybloom_live import BloomFilter

if __name__ == '__main__':

    bf1 = BloomFilter(capacity=1000, error_rate=0.001)
    bf2 = BloomFilter(capacity=1000, error_rate=0.001)
    
    bf1.add(1)
    bf1.add(2)
    
    print("Test 1 in bf1: " + str(1 in bf1))
    print("Test 2 in bf1: " + str(2 in bf1))
    
    with open("/tmp/bloomTest.txt", "wb") as fp:
        bf1.tofile(fp)
    
    with open("/tmp/bloomTest.txt", "rb") as fp2:
        bf2.fromfile(fp2)
        
    print("Test 1 in bf2: " + str(1 in bf2))
    print("Test 2 in bf2: " + str(2 in bf2))

Output:
Test 1 in bf1: True
Test 2 in bf1: True
Test 1 in bf2: False
Test 2 in bf2: False

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions