

Why is truth() faster than bool() in Python? - nerfhammer
http://tellaparteng.tumblr.com/post/57005427993/why-is-truth-faster-than-bool-part-i

======
nemetroid
Uncommon to see such a linkbaitish title for a programming post. The reason
truth() (from operator) is faster than bool() is that

* bool() takes one _optional_ and _named_ argument, and

* truth() takes one argument.

------
pwf
For those wondering what the hell truth() is, I think they're talking about
this phenomenon:

    
    
      python -m timeit "if bool(1): x = 1"
      1000000 loops, best of 3: 0.187 usec per loop
    
      python -m timeit "if 1: x = 1"
      10000000 loops, best of 3: 0.0266 usec per loop

~~~
nemetroid
truth() is a function defined in the operator module which does _kind of_ the
same thing as bool().

------
dhugiaskmak
This article doesn't actually answer the question posed by the title, FYI.

