Q: Pickle compatibility

Martin v. Löwis martin at v.loewis.de
Fri Dec 13 06:18:59 EST 2002


> Yep.  pickles are for version-independent serialization.  Obviously
you
> can't pickle something that involves 2.x features and expect them to
> work when unpickled in a 1.5.x environment, but you the get the idea.

It's not really obvious that this can't work. There are cases where it
fails, e.g. if try to unpickle Unicode objects in Python 1.5. However,
in many other cases, it works out of the box, or can be made to work.
For example, unpickling a Python 2.3 boolean (i.e. true or false) gives
you back a 0/1 integer. Unpickling something else may complain that some
class is not found; if you provide an interface-compatible class in the
older Python version (even if it is a nearly-empty class) allows to
unpickle things that don't normally exist in the older Python version.

Regards,
Martin




More information about the Python-list mailing list