pickle compatibility

Martin v. Loewis martin at v.loewis.de
Sat Jan 26 19:45:15 EST 2002

philh at comuno.freeserve.co.uk (phil hunt) writes:

> If I pickle a Python data structure into a file, then move that file
> to a different machine (with perhaps a different operating system,
> different CPU, and running a different version of Python), will the
> destination machine be able to unpickle the file correctly?

Yes, that will work.

> Does it help if I only use built-in objects?

There is no need. If you pickle class instances, just make sure that
the classes are available at the unpickling end.

> Also, is there some serialisation format that Python uses that is
> standardised so it can be read by non-Python programs?

Several. In Python 2.2, xmlrpclib.dumps should give you a format that
is quite portable. Otherwise, you can try using repr(); that does
require that you use only built-in objects (or else, that repr of your
classes produce easy-to-parse output).


More information about the Python-list mailing list