title: Why is list(x for x in a) faster for a=[0] than for a=[]?
body: <p>I tested <code>list(x for x in a)</code> with three different CPython versions. On <code>a = [0]</code> it's significantly faster than on <code>a = []</code>:</p>
  <pre><code> 3.9.0 64-bit       3.9.0 32-bit       3.7.8 64-bit
  a = []  a = [0]    a = []  a = [0]    a = []  a = [0]
  
  465 ns  412 ns     543 ns  515 ns     513 ns  457 ns   
  450 ns  406 ns     544 ns  515 ns     506 ns  491 ns   
  456 ns  408 ns     551 ns  513 ns     515 ns  487 ns   
  455 ns  413 ns     548 ns  516 ns     513 ns  491 ns   
  452 ns  404 ns     549 ns  511 ns     508 ns  486 ns   
  </code></pre>
  <p>With <code>tuple</code> instead of <code>list</code>, it's the expected other way around:</p>
  <pre><code> 3.9.0 64-bit       3.9.0 32-bit       3.7.8 64-bit
  a = []  a = [0]    a = []  a = [0]    a = []  a = [0]
  
  354 ns  405 ns     467 ns  514 ns     421 ns  465 ns   
  364 ns  407 ns     467 ns  527 ns     425 ns  464 ns   
  353 ns  399 ns     490 ns  549 ns     419 ns  465 ns   
  352 ns  400 ns     500 ns  556 ns     414 ns  474 ns   
  354 ns  405 ns     494 ns  560 ns     420 ns  474 ns   
  </code></pre>
  <p>So why is <code>list</code> faster when it (and the underlying generator iterator) has to do more?</p>
  <p>Tested on Windows 10 Pro 2004 64-bit.</p>
  <p>Benchmark code:</p>
  <pre><code>from timeit import repeat
  
  setups = 'a = []', 'a = [0]'
  number = 10**6
  
  print(*setups, sep='   ')
  for _ in range(5):
      for setup in setups:
          t = min(repeat('list(x for x in a)', setup, number=number)) / number
          print('%d ns' % (t * 1e9), end='   ')
      print()
  </code></pre>
  <p>Byte sizes, showing that it doesn't overallocate for input <code>[]</code> but does for input <code>[0]</code>:</p>
  <pre><code>&gt;&gt;&gt; [].__sizeof__()
  40
  &gt;&gt;&gt; list(x for x in []).__sizeof__()
  40
  
  &gt;&gt;&gt; [0].__sizeof__()
  48
  &gt;&gt;&gt; list(x for x in [0]).__sizeof__()
  72
  </code></pre>