On Sat, Jul 21, 2012 at 5:06 AM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > So there is approximately 0.03 second difference per TWO MILLION > if...else blocks, or about 15 nanoseconds each. This is highly unlikely > to be the bottleneck in your code. Assuming the difference is real, and > not just measurement error, the difference is insignificant.
It's probably real. For if-else, the true case needs to make a jump before it returns, but for if-return, there's no jump and the return is inlined. -- Devin > So, don't worry about which is faster. Write whichever is more natural, > easier to read and write. The most important advice. Even when it's a larger difference! :) -- Devin -- http://mail.python.org/mailman/listinfo/python-list