Though that is perhaps not particularly good Python 3 - style. To me, the idea is
* Implement __lt__ and __eq__ to make objects sortable * Add @functools.total_order if (and only if) that defines a total order * And/Or write your own decorator for different types of order It might be worthwhile to make that difference between just sorting and various orders explicit. Then you could also perform checks like if is_total_ordered(x,y): algorithm_1(x,y) else: algorithm_2(x,y) On Friday, March 6, 2015 at 9:19:27 AM UTC+1, Jeroen Demeyer wrote: > > On 2015-03-06 08:32, Vincent Delecroix wrote: > > __cmp__ is gone in Python 3 see [1]. The way to implement comparisons > > wil be through the various __lt__, __eq__, etc. There is already a > > ticket opened for dealing with that in #16537. It would be better to > > think about a solution that takes this into account. I do not know the > > Cython way. > > I think my ticket is orthogonal to that. It's not because __cmp__ is > gone in Python 3, that we cannot use a Python2-style _cmp_() function to > implement rich comparison. > > Currently, when a rich comparison operator is called on an Element, it > checks for _richcmp_, which is implemented by default using _cmp_. There > is nothing wrong with keeping that behaviour in Python 3. > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.