Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add export and import to file (efficiently) #40

Open
jonsnowseven opened this issue May 30, 2019 · 0 comments
Open

Add export and import to file (efficiently) #40

jonsnowseven opened this issue May 30, 2019 · 0 comments

Comments

@jonsnowseven
Copy link

This is more a feature request than an issue (sorry if it is not the correct place to report this).

Description

I think it could be very useful to have a functionality that exports and imports efficiently a bounter object to and from a file.

Something like:

from bounter import CountMinSketch

cms = CountMinSketch(size_mb=xxx)
cms.update(['a', 'b', 'c', 'a'])
cms.export('file')
cms = CountMinSketch(file='file')
print(cms.counts['a'])

I believe this can be accomplished with this:

import pickle
from bounter import CountMinSketch

cms = CountMinSketch(size_mb=xxx)
cms.update(['a', 'b', 'c', 'a'])
with open('counter.pkl', 'wb') as f:
    pickle.dump(cms, f)

with open('counter.pkl', 'rb') as f:
    cms = pickle.load(f)

print(b.size())
print(b['a'])

But maybe there is a more efficient way to export the object.

Thank you in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant