Hi Kwankyu,

On 27 Mai, 18:10, Kwankyu Lee <ekwan...@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.

> I think we should provide some infrastructure for the developer.

What's wrong with Python's and Cython's pickling infrastructure?

And also note that there are several tools in Sage to create unique
objects. These tools can not only be used for having  "QQ['x'] is
QQ['x']", but they also provide pickling facilities, so that
"loads(dumps(P)) is P".

Example 1:
The module sage.structure.unique_representation.
In particular, consider the function
sage.structure.unique_representation.unpickle and the method
sage.structure.unique_representation.UniqueRepresentation.__reduce__


Example 2:
The module sage.structure.factory.
Cited from the documentation of that module:
    The objects created are cached (using weakrefs) based on their key
and
    returned directly rather than re-created if requested again.
Pickling
    will return the same object for the same version of Sage, and
distinct
    (but hopefully equal) objects for different versions of Sage.

    Typically one only needs to implement create_key and
create_object.

Perhaps you'll like that versioning is addressed, e.g., by
sage.structure.factory.UniqueFactory.get_version. You may also like to
study existing applications of UniqueFactory. From within a sage
session, you may do Integers?? or InfinitePolynomialRing??, which are
two use cases of a unique factory.

> Simon answered to my similar question earlier. However, his answer was not
> sufficient for me to be satisfied.

For the record: That was a part of from
http://groups.google.com/group/sage-devel/browse_thread/thread/faef6072f805c9/c9f8860a647549c1

Cheers,
Simon

-- 
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