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

Added Save() and Load() methods #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

vivekfantain
Copy link

Added save() and load() using pickle and unit tests for the same.

@svpcom
Copy link
Owner

svpcom commented Jul 23, 2018

Why do you need additional 'load' and 'save' methods when it already pickle-friendly?

$ python
Python 2.7.14 (default, Mar 14 2018, 13:36:31) 
[GCC 7.3.1 20180303 (Red Hat 7.3.1-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from hyperloglog import HyperLogLog
>>> a = HyperLogLog(0.05)
>>> from cPickle import loads, dumps
>>> a.add(10)
>>> a.add(20)
>>> a
<hyperloglog.hll.HyperLogLog object at 0x7f1861172cd0>
>>> len(a)
2
>>> b = dumps(a)
>>> b
"ccopy_reg\n_reconstructor\np1\n(chyperloglog.hll\nHyperLogLog\np2\nc__builtin__\nobject\np3\nNtRp4\n(dp5\nS'alpha'\np6\nF0.71978311332173028\nsS'M'\n(lp7\nI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI1\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI1\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\naI0\nasS'm'\nI512\nsS'p'\nI9\nsb."
>>> a = loads(b)
>>> a
<hyperloglog.hll.HyperLogLog object at 0x7f186118f8c0>
>>> len(a)
2

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

Successfully merging this pull request may close these issues.

3 participants