#20998: Removing deprecated cmp and __cmp__ in some pyx files
-------------------------+-------------------------------------------------
       Reporter:         |        Owner:
  chapoton               |
           Type:         |       Status:  needs_work
  enhancement            |
       Priority:  major  |    Milestone:  sage-7.3
      Component:         |   Resolution:
  python3                |
       Keywords:         |    Merged in:
        Authors:         |    Reviewers:  Jeroen Demeyer
  Frédéric Chapoton      |
Report Upstream:  N/A    |  Work issues:
         Branch:         |       Commit:
  public/20998           |  750f6989bdd90aefe29db49fef6a0043c4363865
   Dependencies:         |     Stopgaps:
-------------------------+-------------------------------------------------
Changes (by jdemeyer):

 * status:  needs_info => needs_work
 * reviewer:   => Jeroen Demeyer


Comment:

 1. '''free_algebra_element_letterplace.pyx''', '''semigroups_cython.pyx'''
 and '''map.pyx''':

 `__richcmp__` bypasses the coercion model which is usually not what you
 want for `Element` classes. The rule of thumb is that any
 comparison/arithmetic of Sage `Element`s should use the coercion model
 unless there is a reason not to. Maybe for `FormalCompositeMap`, there is
 not much point in using the coercion model. But
 `FreeAlgebraElement_letterplace` and `LeftZeroSemigroupElement` really are
 elements where coercion looks useful.

 The `_cmp_` and `_richcmp_` methods come from the coercion model, so you
 are guaranteed equal parents, which likely implies that both arguments are
 instances of `FreeAlgebraElement_letterplace`, `LeftZeroSemigroupElement`
 or `FormalCompositeMap`. In that case, you can just drop the type
 comparison.

 2. The function '''richcmp_shortcut''':

 This should be removed and replaced by the standard Python function
 `PyObject_RichCompare`. For an example on how to use it, see
 `src/sage/structure/coerce.pyx`.

--
Ticket URL: <https://trac.sagemath.org/ticket/20998#comment:24>
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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to