On Sunday, October 26, 2014 2:08:27 PM UTC-7, Volker Braun wrote: > > Python 3 only uses __eq__, __lt__, ..... Python also provides > functools.partial_ordering to synthesizing the remaining methods just from > __eq__ and __lt__. We either use that or write a similar decorator to also > deal with coercion. > > The __richcmp__ method is a Cython convention and doesn't exist in plain > Python 3 (or 2 for that matter). >
A little more elaborately: On C-API level PyTypeObject has a tp_richcompare slot with the interface that cython's __richcompare__ has. Cython puts that special method in that slot for a cdef class. Python's "python" classes inherit a tp_richcompare that dispatches to __eq__ and __lt__ methods, probably because the constants Py_EQ etc. were deemed unappetizing to expose on python level. This also means that on cython level, we should stick with __richcompare__ by default, because dispatching to __eq__ python functions would be slow. > -- 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.