title: Why is any (True for ... if cond) much faster than any (cond for ...)?
body: <p>Two similar ways to check whether a list contains an odd number:</p>
  <pre><code>any(x % 2 for x in a)
  any(True for x in a if x % 2)
  </code></pre>
  <p>Timing results with <code>a = [0] * 10000000</code> (five attempts each, times in seconds):</p>
  <pre class="lang-none prettyprint-override"><code>0.60  0.60  0.60  0.61  0.63  any(x % 2 for x in a)
  0.36  0.36  0.36  0.37  0.37  any(True for x in a if x % 2)
  </code></pre>
  <p>Why is the second way almost twice as fast?</p>
  <p>My testing code:</p>
  <pre><code>from timeit import repeat
  
  setup = 'a = [0] * 10000000'
  
  expressions = [
      'any(x % 2 for x in a)',
      'any(True for x in a if x % 2)',
  ]
  
  for expression in expressions:
      times = sorted(repeat(expression, setup, number=1))
      print(*('%.2f ' % t for t in times), expression)
  </code></pre>
  <p><a href="https://tio.run/##TY47DoMwEER7n2IaZBuhKJ8misQt0kUURFkUF9jWepHg9AQ7BWzhZsbzXlzkG/ztHnldBw4jxI3kBG6MgQVMkXpRKpFMES10vz2vc4cal/P/tFI0R6aUXPApxwrb6d4vZkaFK4bAmOE8equbPXzyRIcMbkDp51KnVE724Vw5YB5lJrtmYtpU6WP@smavNSjeDfw0vonbi7XlX2TnxdRGV6frAL1BpYhIppRR2xxodl1/" rel="noreferrer" title="Python 3.8 (pre-release) – Try It Online">Try it online!</a></p>