#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):

 Replying to [comment:56 jdemeyer]:
 > Replying to [comment:55 vdelecroix]:
 > > You wrote in the doc of `_richcmp`
 > > {{{
 > >         If a class wants to implement rich comparison without
 coercion,
 > >         then ``_richcmp`` should be defined (as well as
 ``__richcmp__``
 > >         as usual).
 > > }}}
 > > Why not define directly `__richcmp__` in that case?
 >
 > Because rich comparison after coercion calls `_richcmp`, not
 `__richcmp__`. The only reason this works for `Integer` is that `ZZ` has
 no sub-rings: it is never the common parent of two different parents.

 Right, but `_richcmp` will call `_richcmp_`/`_cmp_`. In Integers (and
 Rationals after #18304) there is also this `_cmp_` implemented and if
 everything else failed in `__richcmp__` there is precisely
 `Element._richcmp(self, other, op)`.

 So even if you implement a subset of `ZZ`/`QQ` as a new parent (let say
 the additive group `3 ZZ` or the ring `ZZ[1/p]`) then it would be fine
 with comparisons with integers/rationals as soon as you define a coercion
 `3 ZZ -> ZZ`/`ZZ[1/p] -> QQ`. So my mistake, the situation for `ZZ` and
 `QQ` is a bit different: `Integer/Rational` do not avoid coercion in rich
 comparisons, they just try to avoid it for most common cases.

 Do you have an example of a `Parent` where we want to avoid coercions?

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