#15692: Value of cached methods should not always be pickled
-------------------------------------+-------------------------------------
Reporter: SimonKing | Owner:
Type: defect | Status: needs_info
Priority: major | Milestone: sage-6.9
Component: pickling | Resolution:
Keywords: pickling hash | Merged in:
cache | Reviewers: Vincent Delecroix
Authors: Julian Rueth | Work issues:
Report Upstream: N/A | Commit:
Branch: | b2aa4073a6724e0c92c719f8d3eb232ef0bc2102
u/saraedum/ticket/15692 | Stopgaps:
Dependencies: #16337 |
-------------------------------------+-------------------------------------
Comment (by nbruin):
Replying to [comment:22 saraedum]:
> Do you have any idea how I could implement that? I could for example
implement {{{__getstate__}}} for sage parents and elements, but then
whenever it is overwritten I would have to rely on the super
implementation being called.
On #15207 there is some discussion of some possible infrastructure for
managing these things. Perhaps it's relevant for your case?
>I could also implement {{{__copy__}}} there which is muss less likely to
be overwritten but still the problem is the same.
I would recommend leaving `__copy__` out of it. That has nothing to do
with the pickling/serialization protocol. It provides a "cheap" way of
replicating a mutable structure (note that for immutable structures,
`__copy__` routinely returns `self`, because immutability implies) so that
mutations of one do not affect the other.
Mutable structures need to take care that they invalidate caches already
(when mutated). I would say that a default behaviour where `copy` creates
a new object with the same caches would be appropriate. The default
behaviour of "copy" is to copy the instance dict, which largely
establishes this.
If this is not appropriate behaviour, it seems to me that the class has
rather special needs and hence should provide its own `__copy__`.
--
Ticket URL: <http://trac.sagemath.org/ticket/15692#comment:23>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.