Noob questions about Python

A.T.Hofkamp hat at se-162.se.wtb.tue.nl
Fri Oct 19 05:27:17 EDT 2007


On 2007-10-19, cokofreedom at gmail.com <cokofreedom at gmail.com> wrote:
> On Oct 19, 1:44 am, MRAB <goo... at mrabarnett.plus.com> wrote:
>> On Oct 18, 7:05 am, Michele Simionato <michele.simion... at gmail.com>
>>
>>     if number == 0:
>>         return "0"
>>
>
> Hey,
>
> Isn't
> if not number:
>   return "0"
>
> faster?

Depends on who is parsing it.

If a computer, possibly a few micro-seconds (if the Python byte-code generator
doesn't optimize it away).

If a human, then it is slower by at least a second.


Since I prefer to optimize on my time rather than CPU time, I'd prefer the
first version

Albert



More information about the Python-list mailing list