On Saturday, December 27, 2014 3:13:37 PM UTC-8, Simon King wrote:
>
> That's exactly what I meant: The use of __eq__, __lt__, etc. is 
> deprecated in Sage, in favour of using __richcmp__ (of course __cmp__ is 
> a different thing). 
>

There is no deprecating of __eq__ or __richcmp__. They appear in different 
contexts (python classes vs. cdef classes to be precise).

In a python class, __eq__, __lt__ etc. are the appropriate methods to 
implement and __richcmp__ isn't a special method at all there, so 
implementing it will not have much effect.

In cython, the __eq__ and __lt__ methods aren't special. There, 
implementing __richcmp__ does the right thing (cython recognizes the method 
name and places it in the relevant slot--the slot that on a python class 
would contain a routine that dispatches to __eq__, __lt__  methods).

I haven't tested it, but I expect that if you put a "class" in a cython 
file instead of a "cdef class", you would also find that you need to 
implement __eq__ and __lt__, because cython wouldn't be in a position to 
place any special routines into slots there.

Python 3 indicates that in sage we *should* be moving entirely to these 
methods. However, historically sage has preferred "cmp". It wouldn't 
surprise me that for backwards compatibility one may still need to provide 
it, until the remaining bits of sage have transitioned to make use of "rich 
comparison".

>    If you implement with 2 underscores, then you bypass the (generic) 
> > coercion implementation. You'd want to implement with a single 
> underscore 
> > to ensure common parents (i.e. _richcm_ or _cmp_). 
>
> Is that so? The comments in structure.elements seem to tell something 
> else.  
>

A brief browsing of the code indicates that there certainly is the 
possibility of implementing these single underscore methods (which is a 
sage API), and I would expect that those would indeed be hooks used by the 
coercion framework.

-- 
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.

Reply via email to