title: Python: any() unexpected performance
body: <p>I am comparing the performance of the <code>any()</code> built-in function with the actual implementation the <a href="https://docs.python.org/2/library/functions.html#any" rel="noreferrer">docs</a> suggest:</p>
  
  <p>I am looking for an element greater than 0 in the following list:</p>
  
  <pre><code>lst = [0 for _ in range(1000000)] + [1]
  </code></pre>
  
  <p>This is the supposedly equivalent function:</p>
  
  <pre><code>def gt_0(lst):
      for elm in lst:
          if elm &gt; 0:
              return True
      return False
  </code></pre>
  
  <p>And these are the results of the performance tests:</p>
  
  <pre><code>&gt;&gt; %timeit any(elm &gt; 0 for elm in lst)
  &gt;&gt; 10 loops, best of 3: 35.9 ms per loop
  
  &gt;&gt; %timeit gt_0(lst)
  &gt;&gt; 100 loops, best of 3: 16 ms per loop
  </code></pre>
  
  <p>I would expect both of the to have the exact same performance, however <code>any()</code> if two times slower. Why?</p>