overriding methods - two questions

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sat Nov 17 03:08:10 EST 2007


En Sat, 17 Nov 2007 01:56:22 -0300, Donn Ingle <donn.ingle at gmail.com>  
escribió:

> for obj in list:
>  if 'foo' in obj.__class__.__dict__:
>   etc.
>
> Although I am concerned that it's a loop ('in') and so may be slower than
> some other way to detect foo().

'in' for dictionaries is fast and runs in constant time. You may be  
thinking about 'in' for lists, that runs in time proportional to the  
number of elements.

-- 
Gabriel Genellina




More information about the Python-list mailing list