#16127: Fix comparison of PARI objects
-------------------------------------+-------------------------------------
       Reporter:  pbruin             |        Owner:
           Type:  defect             |       Status:  needs_info
       Priority:  critical           |    Milestone:  sage-6.4
      Component:  interfaces         |   Resolution:
       Keywords:  pari comparison    |    Merged in:
        Authors:  Peter Bruin        |    Reviewers:  Jeroen Demeyer
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/jdemeyer/ticket/16127            |  12fbcad65c6438fe0495c3b2424468f24b49a9ee
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by pbruin):

 Replying to [comment:22 jdemeyer]:
 > Replying to [comment:18 pbruin]:
 > > in my opinion asking whether `a <= b` only makes sense if `a` and `b`
 are in some partially ordered set (like the real numbers with plus and
 minus infinity).
 > In that case, we should give an exception when asking for `a <= b`. I
 think returning False is more wrong than returning True when the objects
 are equal.
 OK, I think raising an error is conceptually and technically the right
 solution.  Earlier I wrongly convinced myself that comparison operators
 should never fail, but since they can, it makes sense to keep the
 behaviour of `gen` objects under comparison as close as possible to what
 PARI does, if only for efficiency reasons.

 It turns out that there are only a few places where Sage tries to sort
 unordered PARI objects (polynomials, in fact).  We can basically use
 `list.sort(cmp=cmp)` to force the use of `__cmp__()` instead of the rich
 comparison operators.  In two cases (`enumerate_totallyreal_fields_*`) it
 is a bit more tricky, but after the necessary modifications the code
 actually becomes cleaner in my opinion (and not measurably slower).

 Now testing if this approach works, and if it keeps working after
 experimentally replacing string comparison by PARI's `cmp_universal()`.

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