# HG changeset patch
# User Robert Bradshaw <robertwb@math.washington.edu>
# Date 1228256529 28800
# Node ID 271b85456f9c56cbc95f7e007cc440a165411b62
# Parent 186599acb5d1acdaf337981a72df97855262bb2e
[mq]: 4639-coerce-leak
diff -r 186599acb5d1 -r 271b85456f9c sage/categories/homset.py
|
a
|
b
|
|
| 60 | 60 | key = (X,Y,cat) |
| 61 | 61 | if _cache.has_key(key): |
| 62 | 62 | H = _cache[key]() |
| 63 | | if H: return H |
| | 63 | if H and H._domain is X and H._codomain is Y: |
| | 64 | return H |
| 64 | 65 | |
| 65 | 66 | if cat is None or (cat is X.category() and cat is Y.category()): |
| 66 | 67 | try: |
| … |
… |
|
| 149 | 150 | else: |
| 150 | 151 | H = Homset(X, Y, cat) |
| 151 | 152 | |
| 152 | | ##_cache[key] = weakref.ref(H) |
| | 153 | _cache[key] = weakref.ref(H) |
| 153 | 154 | _cache[(X, Y, cat)] = weakref.ref(H) |
| 154 | 155 | |
| 155 | 156 | return H |
diff -r 186599acb5d1 -r 271b85456f9c sage/rings/finite_field_morphism.py
|
a
|
b
|
|
| 3 | 3 | from sage.rings.integer import Integer |
| 4 | 4 | from sage.structure.sequence import Sequence |
| 5 | 5 | |
| 6 | | class FiniteFieldHomset(RingHomset_generic): |
| | 6 | import weakref |
| | 7 | |
| | 8 | _cache = {} |
| | 9 | def FiniteFieldHomset(R, S): |
| | 10 | """ |
| | 11 | TESTS: |
| | 12 | sage: F = GF(13) |
| | 13 | sage: Hom(F,F) is Hom(F,F) |
| | 14 | True |
| | 15 | """ |
| | 16 | key = R,S |
| | 17 | if _cache.has_key(key): |
| | 18 | H = _cache[key]() |
| | 19 | if H: |
| | 20 | return H |
| | 21 | H = FiniteFieldHomset_class(R,S) |
| | 22 | _cache[key] = weakref.ref(H) |
| | 23 | return H |
| | 24 | |
| | 25 | class FiniteFieldHomset_class(RingHomset_generic): |
| 7 | 26 | """ |
| 8 | 27 | Set of homomorphisms with domain a given finite field. |
| 9 | 28 | """ |