#16537: Python 3 preparation: Use "rich comparison" - std function cmp() is
gone,
method __cmp__ is ignored
---------------------------------+------------------------
Reporter: wluebbe | Owner:
Type: PLEASE CHANGE | Status: new
Priority: major | Milestone: sage-6.3
Component: distribution | Resolution:
Keywords: python3 | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
---------------------------------+------------------------
Comment (by wluebbe):
Some remarks on the attached files:
* The 1st script shows the effects of varying which of the special methods
{{{__eq__, __ne__, __lt__}}} and {{{@total_ordering}}} are defined. The
2nd and 3rd files show the results for Py2 and Py3 respectively.
* In Py2 all of ("eq", "ne", "lt", "total") must be used to always
obtain correct results.
* In Py3 it appears that "ne" is implied (be "eq").
* For correct behavior in Py2 and Py3 all of "eq", "ne", "lt", "total"
should be used.
* The 4th script shows the results of the comparison operators when
defining no {{{__cmp_}}} or using a self defined {{{cmp}}} or using the
standard library {{{cmp}}}. The 5th and 6th files show the results for Py2
and Py3 respectively.
* In Py2 "no_cmp" gives often wrong results, but always correct results
when {{{__cmp__}}} is defined.
* In Py3 there are always type errors for "lt", "le", "gt"and "ge". For
"eq" and "ne" some wrong and some correct.
* {{{__cmp__}}} does not work in Py3! Rich comparison must be
implemented!
* The 7th script shows whether it possible to define the rich comparison
special methods using {{{cmp}}}. The 8nd and 9th files show the results
for Py2 and Py3 respectively.
* In Py2 it is possible.
* In Py3 one needs a user defined {{{cmp}}} function that is based on
{{{<}}} and {{{>}}}.
* Both in Py2 and Py3 {{{@total_ordering}}} is required.
--
Ticket URL: <http://trac.sagemath.org/ticket/16537#comment:2>
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.