#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:29 SimonKing]:
> > 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.
>
> I still don't understand what it is supposed to mean. What do you mean
by "manually inherit"?
An extension type with the `InheritComparisonMetaclass` "metaclass" will
inherit `__cmp__` and `__richcmp__` from its base class if neither
`__cmp__` nor `__richcmp__` is defined.
In practice, it means that we no longer need the boilerplate code
{{{
def __richcmp__(left, right, int op):
return (<Element>left)._richcmp(right, op)
def __cmp__(left, right):
return (<Element>left)._cmp(right)
}}}
in subclasses of `Element` since those will be inherited from `Element`.
--
Ticket URL: <http://trac.sagemath.org/ticket/18329#comment:30>
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.