'if foo' calls getattr?!?

Moshe Zadka moshez at server.python.net
Tue Aug 31 01:27:35 EDT 1999

On Mon, 30 Aug 1999, Gordon McMillan wrote:

[about how hard it is to know the truth in Python]
> In which case "if foo is not None" will be the fastest and 
> closest-to-your-intention test possible. (But "if foo != None" will 
> get you right back to where you are now!).

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.

More information about the Python-list mailing list