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

 * status:  needs_review => needs_info


Comment:

 9. implementation of `_(rich)cmp`:
   - Why in `_(rich)cmp` it starts with the case `not
 have_same_parent_c(left,right)` instead of
 `have_same_parent_c(left,right)`. It would make it more readable the other
 way around.
 {{{
 cdef _richcmp(left, right):
     if have_same_parent_c(left, right):
         return left._richcmp_(<Element>right, op)

     # different parents
     global coercion_model
     cdef int r
     ...
 }}}
   - In `return left._(rich)cmp_(<Element>right, op)` is the `<Element>`
 really needed or usefull?
   - could `_left, _right = coercion_model.canonical_coercion(left, right)`
 be replaced with `left, right = coercion_model.canonical_coercion(left,
 right)`. As far as I see, there is no need of these extra variables.

 10. Could you some minimal documentation to `_(rich)cmp` and `_(rich)cmp_`
 like
 {{{
 def _richcmp(left, right):
     r"""
     Rich comparisons of elements

     This should not be overriden! To implement comparisons override
 ``_richcmp_``
     or/and ``_cmp_``.
     """

 def _richcmp_(left, right):
     r"""
     Default implementation of rich comparisons for elements

     By default it tries to see if `_cmp_` is implemented otherwise does a
     comparison by id for ``==`` and ``!=``. Calling this default method
     with ``<``, ``<=``, ``>`` or ``>=`` will raise a
 ``NotImplementedError``.

     EXAMPLES::

         sage: from sage.structure.parent import Parent
         sage: from sage.structure.element import Element
         sage: P = Parent()
         sage: e1 = Element(P); e2 = Element(P)
         sage: e1 == e1    # indirect doctest
         True
         sage: e1 == e2    # indirect doctest
         False
         sage: e1 < e2     # indirect doctest
         Traceback (most recent call last):
         ...
         NotImplementedError: comparison not implemented for
         <type 'sage.structure.element.Element'>
     """
 }}}
  and I think that `_cmp_` and `_richcmp_` deserves a sphinx directive to
 make them appear in the reference manual.

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