pickle's backward compatibility

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Oct 13 02:02:50 CEST 2009

En Mon, 12 Oct 2009 12:17:52 -0300, Peng Yu <pengyu.ut at gmail.com> escribió:

> If I define my own class and use pickle to serialize the objects in
> this class, will the serialized object be successfully read in later
> version of python.

 From <http://docs.python.org/library/pickle.html>: "The pickle  
serialization format is guaranteed to be backwards compatible across  
Python releases."
What you save now should be readable by a later version. Your own class  
must be able to process what you saved (regarding added/deleted/renamed  
attributes, changes in meaning, renamed/moved classes...)

> What if I serialize (using pickle) an object of a class defined in
> python library, will it be successfully read in later version of
> python?

As JPC said: no guarantees.

Gabriel Genellina

More information about the Python-list mailing list