#16316: cached_function and cached_method for unhashable elements
-------------------------------------+-------------------------------------
Reporter: saraedum | Owner:
Type: enhancement | Status: needs_review
Priority: minor | Milestone: sage-6.3
Component: misc | Resolution:
Keywords: | Merged in:
Authors: Julian Rueth | Reviewers: Peter Bruin
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/pbruin/16316-cache_key | c0a7fb816bff291f99053b623bf07468190eb49c
Dependencies: #16251 | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by pbruin):
I do not really see the problem here. The objects may be "unhashable" in
the sense that they don't have a `__hash__()` method, but they don't
change over time, so we can consistently attach a hash value to them ''for
the purpose of caching'' by hashing the `cache_key` instead.
It may be useful to emphasize that it is not the ''input'' of a cached
function that is cached, but the ''output''. The cache (dictionary) key
is not necessarily the input itself, it is just some (hashable) object
containing enough information to distinguish different input values and
that can be consistently extracted from a given input value. Of course in
most cases the key ''is'' the input, but it does not have to be, as this
ticket shows.
Maybe the formulation "caching works for objects which are not hashable"
that appears is several doctests is slightly vague, but I personally won't
insist on changing it.
--
Ticket URL: <http://trac.sagemath.org/ticket/16316#comment:17>
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.