pointless musings on performance

mk mrkafk at gmail.com
Tue Nov 24 08:41:19 EST 2009


MRAB wrote:
> In what way is it counterintuitive? In 'pythonic' the conditions are
> simpler, less work is being done, therefore it's faster.

But the pythonic condition is more general: nonevar or zerovar can be 
'', 0, or None. So I thought it was more work for interpreter to compare 
those, while I thought that "is not None" is translated to one, more 
low-level and faster action. Apparently not.

As Rob pointed out (thanks):

11          31 LOAD_FAST                0 (nonevar)
              34 JUMP_IF_FALSE            4 (to 41)

I'm no good at py compiler or implementation internals and so I have no 
idea what bytecode "JUMP_IF_FALSE" is actually doing.

Regards,
mk





More information about the Python-list mailing list