[Cython] list.index(instance) by identity or __eq__?
Robert Bradshaw
robertwb at math.washington.edu
Thu Oct 9 19:46:17 CEST 2008
On Oct 8, 2008, at 12:15 PM, Aaron DeVore wrote:
> I'm writing a class/type that will be inserted into a list. After it
> is inserted the developer should be able to call
> a_list.index(my_type_instance) and get the my_type_instance index by
> *identity*, not by a call to my_type.__eq__. I have a my_type.__eq__
> function but it doesn't give the correct behavior. Which behavior does
> Cython use?
I think the issue you're running into is that Python extension
classes use rich comparison rather than __eq__ and friends. See
http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/
Manual/special_methods.html .
- Robert
More information about the Cython-dev
mailing list