# HG changeset patch
# User Xavier Caruso
# Date 1341738209 -7200
# Node ID 059a3d1ed922b07d14220a897487f100ac8e4a70
# Parent 63f47e1ba4934889f123e13a4471e2719431fbb3
Trac #13184: Unique parent assumption for homset
diff --git a/sage/categories/homset.py b/sage/categories/homset.py
--- a/sage/categories/homset.py
+++ b/sage/categories/homset.py
@@ -154,9 +154,17 @@
TESTS:
- Some doc tests in :mod:`sage.rings` (need to) break the unique parent assumption.
- But if domain or codomain are not unique parents, then the hom set won't fit.
- That's to say, the hom set found in the cache will have a (co)domain that is
+ Homset are unique parents::
+
+ sage: k = GF(5)
+ sage: H1 = Hom(k,k)
+ sage: H2 = Hom(k,k)
+ sage: H1 is H2
+ True
+
+ However, some doc tests in :mod:`sage.rings` (need to) break the unique parent
+ assumption. If domain or codomain are not unique parents, then the hom set won't
+ fit. That's to say, the hom set found in the cache will have a (co)domain that is
equal to, but not identic with, the given (co)domain.
By trac ticket #9138, we abandon the uniqueness of hom sets, if the domain or
@@ -222,7 +230,11 @@
try:
# Apparently X._Hom_ is supposed to be cached
- return X._Hom_(Y, category)
+ # but it is not in some cases (e.g. X is a finite field)
+ # To be investigated
+ H = X._Hom_(Y,category)
+ _cache[key] = weakref.ref(H)
+ return H
except (AttributeError, TypeError):
pass