Live data from Hacker News

Don't Pickle Your Data

benfrederickson.com

1–10 of 26 posts

Re: Don't Pickle Your Data

#6
"Use pickle with caution" would be better advice. There are plenty of cases where your data is under control and pickle is a huge time saver. It takes work to translate most data structures to/from json.

Re: Don't Pickle Your Data

#7
JSON, while a fantastic lightweight data format, is insufficient for storing even moderately complex objects. It can not properly differentiate between tuples and lists, it can only accept strings for object keys, and it only stores unicode strings.

You also have to write custom (de)serializers if you want to store datetime objects (my personal pet peeve), any of the special python containers... basically any time you want anything other than an object, array, string or number.

Unless I'm dealing with untrusted data sources, or need to interoperate with other languages, I will keep using Pickle.

Re: Don't Pickle Your Data

#9
post #3

This benchmark doesn't specify a pickle protocol, which forces Python to use a big, inefficient format. I filed a bug. https://github.com/benfred/bens-blog-code/issues/1

This is a huge thing he missed. Anyone using pickle for non-trivial work is doing cPickle with PROTOCOL_HIGHEST.

Re: Don't Pickle Your Data

#10
post #7

JSON, while a fantastic lightweight data format, is insufficient for storing even moderately complex objects. It can not properly differentiate between tuples and lists, it can only accept strings for object keys, and it only stores unicode strings. You also have to write custom (de)serializers if you want to store datetime objects (my personal pet peeve), any of the special python containers... basically any time yo…

[deleted]
Post reply on HN