Ticket #13184: trac_13184_homset_unique_parent

File trac_13184_homset_unique_parent, 1.6 KB (added by caruso, 10 years ago)
Line
1# HG changeset patch
2# User Xavier Caruso <xavier.caruso@normalesup.org>
3# Date 1341738209 -7200
4# Node ID 09ba9b7f74b31e781e40c0f2bbe765e6c9c7bdb2
5# Parent  c4bdbf18dd78c13ff3032e07a3f355b8632ac054
6Trac #13184: Unique parent assumption for homset
7
8diff --git a/sage/categories/homset.py b/sage/categories/homset.py
9--- a/sage/categories/homset.py
10+++ b/sage/categories/homset.py
11@@ -154,9 +154,17 @@
12
13     TESTS:
14
15-    Some doc tests in :mod:`sage.rings` (need to) break the unique parent assumption.
16-    But if domain or codomain are not unique parents, then the hom set won't fit.
17-    That's to say, the hom set found in the cache will have a (co)domain that is
18+    Homset are unique parents::
19+
20+        sage: k = GF(5)
21+        sage: H1 = Hom(k,k)
22+        sage: H2 = Hom(k,k)
23+        sage: H1 is H2
24+        True
25+
26+    However, some doc tests in :mod:`sage.rings` (need to) break the unique parent
27+    assumption. If domain or codomain are not unique parents, then the hom set won't
28+    fit. That's to say, the hom set found in the cache will have a (co)domain that is
29     equal to, but not identic with, the given (co)domain.
30
31     By trac ticket #9138, we abandon the uniqueness of hom sets, if the domain or
32@@ -221,8 +229,12 @@
33             return H
34
35     try:
36-        # Apparently X._Hom_ is supposed to be cached
37-        return X._Hom_(Y, category)
38+        # Actually X._Hom_ is supposed to be cached
39+        # but it is not in some cases (e.g. X is a finite field)
40+        # To be investigated
41+        H = X._Hom_(Y,category)
42+        _cache[key] = weakref.ref(H)
43+        return H
44     except (AttributeError, TypeError):
45         pass
46