On Oct 10, 2008, at 12:28 AM, Aaron DeVore wrote:

> Tragically, I can't show my implementation of __eq__. However, I will
> say this: I absolutely cannot change __eq__ to work with identities.
>
> For a relatively short list (usually 0-20 items, sometimes up to 1000)
> would this work and still be blindingly fast? "----" indicates
> indentation.:
>
> int index
> for index from 0 <= index < len(a_list):
> ----if a_list[index] is my_type_instance:
> --------break

This will compare on identity, if that's what you want then it should  
be quite fast.

> Or would I need to do this to get correct behavior:
> int index
> for index from 0 <= index < len(a_list):
> ----if id(a_list[index]) == id(my_type_instance):
> --------break

This is essentially how list.index() is implemented.

>
> 2008/10/9 Lisandro Dalcin <[EMAIL PROTECTED]>:
>> On Wed, Oct 8, 2008 at 4:15 PM, Aaron DeVore  
>> <[EMAIL PROTECTED]> wrote:
>>> I have a my_type.__eq__
>>> function but it doesn't give the correct behavior. Which behavior  
>>> does
>>> Cython use?
>>
>> Could you show us the way you implemented your __eq__ method?
>>
>>
>>
>> --
>> Lisandro Dalcín
>> ---------------
>> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
>> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
>> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
>> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
>> Tel/Fax: +54-(0)342-451.1594
>> _______________________________________________
>> Cython-dev mailing list
>> [email protected]
>> http://codespeak.net/mailman/listinfo/cython-dev
>>
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to