'if foo' calls getattr?!?

Moshe Zadka moshez at server.python.net
Tue Aug 31 07:50:42 CEST 1999


On Tue, 31 Aug 1999, Moshe Zadka wrote:

> Bzzt! foo!=None is slower then foo is not None, but not by much: it will
> first check whether type(foo) is not type(None), so it is pretty fast.
> 
> truth-and-nothing-are-always-popular-subjects-ly y'rs, Z.

Sorry to reply to my own posts, but there was a mistake: foor!=None will
make a call to __getattr__ for __cmp__, so it will be very slow.

oops-ly y'rs, Z.





More information about the Python-list mailing list