#14214: Cythoned homsets
----------------------------------------------+-----------------------------
Reporter: SimonKing | Owner: tbd
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.8
Component: performance | Resolution:
Keywords: Hom, cython, cached method | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Simon King | Merged in:
Dependencies: #14159, #12951 | Stopgaps:
----------------------------------------------+-----------------------------
Comment (by SimonKing):
Replying to [comment:4 nthiery]:
> Yes, I don't why we should not cache Hom(X,Y).
OK, doing it soon.
In fact, what I do now: Try to implement the new coercion framework for
all homsets (hence: Remove `__call__`, use element classes). I am already
getting less than a couple of hundred errors...
> By the way, is there a
> reason why Hom is not a (weak) cached function rather than handling
> it's cache by hand?
Yes, actually three reasons:
- A weak cached function has a weak reference on the value, but not on the
keys. But we need weak references on the keys, for otherwise a memory leak
arises.
- In the coercion framework, the domain of a map ''must'' be identical
(and not just equal) to the parents of elements-to-be-coerced. Hence, if
X' is equal to X, then we need that Hom(X,Y) is not identical with
Hom(X',Y). But a weak cached function would compare by equality, and this
would give rise to errors in those parts of Sage that still work with non-
unique parents. `TripleDict` does compare the keys by identity.
- We know that the keys are triples (domain, codomain, category). I think
we have benchmarks showing that `TripleDict` is faster than a python
dictionary.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14214#comment:5>
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.