#14214: Cythoned homsets
----------------------------------------------+-----------------------------
Reporter: SimonKing | Owner: tbd
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-5.10
Component: performance | Resolution:
Keywords: Hom, cython, cached method | Work issues: How to store
domain and codomain?
Report Upstream: N/A | Reviewers:
Authors: Simon King | Merged in:
Dependencies: #14159, #12951, #13184 | Stopgaps:
----------------------------------------------+-----------------------------
Comment (by nbruin):
Replying to [comment:55 SimonKing]:
> And I guess you could get it still a bit faster, if you do `def
__get__(self, Parent instance, cls)`, because our homsets are parents, and
because the cdef public attribute `__cached_methods` could be accessed
more quickly if the instance is known to be a Parent.
Excellent idea! if `__cached_method` isn't in a slot then we wouldn't want
to use it anyway. It does mean that we lose flexibility: If for some
reason, we have a class that can't inherit directly from Parent but does
want to cooperate in this protocol, it won't be able to.
> And that's the second question: Are you really sure that lazy_attribute
will be as fast as `CachedAttributeType` in the case of no `__dict__`?
My timings suggested this. However, I suspect that providing cdef access
to `__cached_method` will be a (small) measurable gain, so with that
specialization you should be faster.
> Note that I tested to cythonize lazy_attribute ''and'' to cimport
Parent. It failed (circular import or so).
That can't be `lazy_attribute`, or at least not my version. It doesn't
have any imports!
So, we come back to the first question: Where shall we put the code? I
think it makes sense to cdefine `instance` being Parent, but this would be
impossible in `sage/misc/lazy_attribute.pyx`.
If it's a parent-specific support class it can just go with the parent
source, right?
> And the third question is: Shall we really make this ticket depend on a
proper cythonized version of lazy_attribute?
Not if you go the Parent-specific `CachedAttribute` route. That would be a
bad name, by the way. Perhaps `ParentAttributeBacker` is better.
> all our homsets are Python subclasses of the (now cythonized) Homset.
Talk about academic code then ... I'm sure we'll get cythonized homset
instances at some point.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14214#comment:56>
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.