Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit b41c455

Browse files
committed
restore previous version of _cache_key() in cachefunc.pyx
1 parent 7a9a6b2 commit b41c455

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/sage/misc/cachefunc.pyx

+10-5
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,16 @@ def _cache_key(o):
553553
sage: _cache_key(o)
554554
(1/2, (..., ((1,),), 0, 20))
555555
"""
556-
if isinstance(o, sage.structure.sage_object.SageObject):
557-
o = o._cache_key()
558-
if isinstance(o, tuple):
559-
return tuple(_cache_key(item) for item in o)
560-
return o
556+
try:
557+
hash(o)
558+
return o
559+
except TypeError:
560+
if isinstance(o, sage.structure.sage_object.SageObject):
561+
o = o._cache_key()
562+
if isinstance(o,tuple):
563+
return tuple(_cache_key(item) for item in o)
564+
else:
565+
return o
561566

562567
cdef class CachedFunction(object):
563568
"""

0 commit comments

Comments
 (0)