Hi Simon,

I thought of the proposal while fixing unpickling problem of the patch for 
TermOrder objects for

http://trac.sagemath.org/sage_trac/ticket/11316

The situation I described originally is of course what I faced while fixing 
the problem.

On 27 Mai, 18:10, Kwankyu Lee <ekwa...@gmail.com> wrote: 
> > How does Sage solve the following situation? A user stores objects 
> pickled 
> > in Sage version X.1. Then a developer changes internal logic and data 
> > structure of the class of the objects for Sage version X.2. If we assume 
> the 
> > developer's patch is merged to Sage X.2, then typically the user's 
> objects 
> > fail to be unpickled in Sage X.2. 
>
> No. Typically they won't fail. The reason is that the way an object is 
> pickled has typically 
> *nothing* to do with the *internal* data structure. The serialisation 
> is based on some data (such as tuples of coefficients, strings that 
> provide a name, etc), and on an unpickling function that is able to 
> create an object out of the given data. 
>
> So, a pickle from version X.1 will only fail to be readable in version 
> X.2 if the *interface of the unpickling function* has changed. 

 
My understanding of the pickling procedure came from the Python 
documentation. A relevant passage is:
------------------------------------
... when class instances are pickled, their class’s code and data are not 
pickled along with them. Only the instance data are pickled. This is done on 
purpose, so you can fix bugs in a class or add methods to the class and 
still load objects that were created with an earlier version of the class. 
If you plan to have long-lived objects that will see many versions of a 
class, it may be worthwhile to put a version number in the objects so that 
suitable conversions can be made by the class’s 
__setstate__()<http://docs.python.org/library/pickle.html#object.__setstate__>method.
-------------------------------------
This seemed to be true at least for the pickled TermOrder objects.
 
Kwankyu

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to