#15692: Value of cached methods should not always be pickled
-------------------------+---------------------------------------
   Reporter:  SimonKing  |            Owner:
       Type:  defect     |           Status:  new
   Priority:  major      |        Milestone:  sage-6.1
  Component:  pickling   |         Keywords:  pickling hash cache
  Merged in:             |          Authors:
  Reviewers:             |  Report Upstream:  N/A
Work issues:             |           Branch:
     Commit:             |     Dependencies:
   Stopgaps:             |
-------------------------+---------------------------------------
 In #15278, the hash of graphs was turned into a `@cached_method`. If a
 cached method is pickled, then the cached value is pickled as well. In the
 case of a hash value, this is not always what we want, since the hash
 value might depend on the memory address of an object, or worse: The hash
 function might change in future implementations.

 That's to say: If you save object O now, together with hash value 123, and
 later load it, then hash(O) will still be 123, even if a newly constructed
 object P with O==P might have hash(P)==456, because of a change in the
 hash function.

 This obviously is a problem. There is something called
 `sage.misc.cachefunc.ClearCacheOnPickle`, but I don't know if this would
 really help in this case. Also, this would clear ''all'' cache values at
 once. Also, I don't know if it works for cached methods that do not take
 arguments (beside `self`).

 I suggest that we should instead have an optional parameter for
 `sage.misc.cachefunc.CachedMethodCallerNoArgs` that determines whether or
 not the cached value is preserved, and use it on graphs (and future
 applications of cached method on `__hash__`).

--
Ticket URL: <http://trac.sagemath.org/ticket/15692>
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/groups/opt_out.

Reply via email to