Best way to save complex Python data structures across program sessions (pickle, json, xml, database

Posted by Malcolm on Stack Overflow See other posts from Stack Overflow or by Malcolm
Published on 2010-01-05T01:57:23Z Indexed on 2010/05/01 18:47 UTC
Read the original article Hit count: 320

Filed under:
|
|
|

Looking for advice on the best technique for saving complex Python data structures across program sessions.

Here's a list of techniques I've come up with so far:

  • pickle/cpickle
  • json
  • jsonpickle
  • xml
  • database (like SQLite)

Pickle is the easiest and fastest technique, but my understanding is that there is no guarantee that pickle output will work across various versions of Python 2.x/3.x or across 32 and 64 bit implementations of Python.

Json only works for simple data structures. Jsonpickle seems to correct this AND seems to be written to work across different versions of Python.

Serializing to XML or to a database is possible, but represents extra effort since we would have to do the serialization ourselves manually.

Thank you, Malcolm

© Stack Overflow or respective owner

Related posts about python

Related posts about pickle