#17890: Remove _(rich)cmp_c_impl
-------------------------------------+-------------------------------------
       Reporter:  jdemeyer           |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.7
      Component:  cython             |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Jeroen Demeyer     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/jdemeyer/ticket/17890            |  04570b3dfd194fea8c2437c8717c3dfb8704b4af
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by vdelecroix):

 I would really like the following in `Element._richcmp_`
 {{{#!diff
 diff --git a/src/sage/structure/element.pyx
 b/src/sage/structure/element.pyx
 index 6981135..12cb669 100644
 --- a/src/sage/structure/element.pyx
 +++ b/src/sage/structure/element.pyx
 @@ -1047,11 +1047,21 @@ cdef class Element(SageObject):
              ...
              NotImplementedError: comparison not implemented for <type
 'sage.structure.element.Element'>
          """
          # Obvious case
          if left is right:
              return rich_to_bool(op, 0)

          cdef int c
 +        if op == Py_NE:
 +            try:
 +                left_eq = left.__eq__
 +            except AttributeError:
 +                pass
 +            else:
 +                if isinstance(left_eq, MethodType):
 +                    return False if left_eq(right) else True
 +
          try:
              c = left._cmp_(right)
          except NotImplementedError:
 }}}
 that would allow element implementing `__eq__` to benefit of `__ne__` for
 free. What do you think? Perhaps not for this ticket though (thinking
 about #18305). It is a bit dangerous since `__eq__` would not go through
 coercions but `__ne__` would.

--
Ticket URL: <http://trac.sagemath.org/ticket/17890#comment:62>
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.

Reply via email to