#14214: Cythoned homsets
-------------------------------------+-------------------------------------
Reporter: SimonKing | Owner: tbd
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-6.4
Component: performance | Resolution:
Keywords: Hom, cython, | Merged in:
cached method | Reviewers:
Authors: Simon King | Work issues: How to store domain
Report Upstream: N/A | and codomain?
Branch: | Commit:
Dependencies: #14159, #12951, | Stopgaps:
#13184 |
-------------------------------------+-------------------------------------
Comment (by SimonKing):
Replying to [comment:1 SimonKing]:
> `sage.modular.abvar.homspace.EndomorphimSubring` inherits from
sage.categories.homset.Homset and from sage.rings.ring.Ring. Making Homset
cdef with cdef attributes results in incompatible base classes.
>
> - One could think of creating a new cdef class
`sage.categories.homset.EndomorphismRing` inheriting from
sage.rings.ring.Ring and copying the methods implemented in
sage.categories.homset.Homset, and use it in sage.modular.abvar.homspace.
> - However, that's code duplication, and I doubt that we want that.
> - One could think of dropping `sage.rings.ring.Ring` and let
`EndomorphismSubring` entirely rely on the ring functionality that is
provided by the category framework.
Note that this should now be a lot easier, by #18756.
> - I tried, but this means opening a can of worms. One would then also
need to implement the new coercion model in sage.modular. But replacing
`EndomorphismSubring.__call__` by an _element_constructor_ does not work,
because Homset has a `__call__` method, too. Hence, we would then also
need to use the new coercion model for sage.categories.homset. Yes, that's
desirable. But it is not available in short time.
See #14279, but both this ticket and #14279 need work.
> __Short term improvements suggested in my patch__
>
> - Accessing a Python attribute _domain defined for a Homset can be
surprisingly slow. It is fast, if one has an instance of Homset itself.
But it is slow if one considers an instance of a sub-class, such as
`EndomorphismSubring`. It turns out that calling a cached method is
''faster'' than accessing the attribute! Hence, I suggest using cached
method decorators on the domain() and codomain() methods (these methods
are internally used in `EndomorphismSubring` anyway).
If I recall correctly, that's not the case any longer. However, if we are
able to avoid double inheritance from `Homset` and `Ring`, there is not
obstruction for making `_domain` and `_codomain` cdef.
--
Ticket URL: <http://trac.sagemath.org/ticket/14214#comment:71>
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.
For more options, visit https://groups.google.com/d/optout.