#18329: Inherit __richcmp__ and __cmp__ in subclasses of Element
-------------------------------------+-------------------------------------
Reporter: jdemeyer | Owner:
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-6.7
Component: coercion | Resolution:
Keywords: | Merged in:
Authors: Jeroen Demeyer | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/jdemeyer/ticket/18329 | 4b08519ef79528cce58738b501751f1d5db9f519
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by jdemeyer):
Replying to [comment:27 SimonKing]:
> Can you tell how it actually works?
There are two things you need to know:
1. The Cython "metaclass" mechanism implemented in #18330. This is similar
to but not the same as a Python metaclass. It is a mechanism to change the
`type()` of a Cython extension type and call the `__init__` method (but
not `__new__`!) of the metaclass. Using the C preprocessor, a hook to
implement this is added which is called whenever a Cython extension type
is created.
2. This ticket uses that mechanism to manually inherit the `tp_compare`
and `tp_richcompare` slots of extension types, see the code in
`src/sage/misc/inherit_comparison.pyx` in the branch.
> And of course, when cythoning the elements of a combinatorial free
module, `__cmp__` and `__richcmp__` would still be copied rather than
inherited from sage.structure.element.
What do you mean with "would still be copied"? I don't understand what
you're trying to say.
--
Ticket URL: <http://trac.sagemath.org/ticket/18329#comment:28>
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.