title: Why is copying a shuffled list much slower?
body: <p>Copying a shuffled <code>range(10**6)</code> list ten times takes me about 0.18 seconds: (these are five runs)</p>
  
  <pre><code>0.175597017661
  0.173731403198
  0.178601711594
  0.180330912952
  0.180811964451
  </code></pre>
  
  <p>Copying the unshuffled list ten times takes me about 0.05 seconds:</p>
  
  <pre><code>0.058402235973
  0.0505464636856
  0.0509734306934
  0.0526022752744
  0.0513324916184
  </code></pre>
  
  <p>Here's my testing code:</p>
  
  <pre><code>from timeit import timeit
  import random
  
  a = range(10**6)
  random.shuffle(a)    # Remove this for the second test.
  a = list(a)          # Just an attempt to "normalize" the list.
  for _ in range(5):
      print timeit(lambda: list(a), number=10)
  </code></pre>
  
  <p>I also tried copying with <code>a[:]</code>, the results were similar (i.e., big speed difference)</p>
  
  <p>Why the big speed difference? I know and understand the speed difference in the famous <a href="https://stackoverflow.com/q/11227809/1672429">Why is it faster to process a sorted array than an unsorted array?</a> example, but here my processing has no decisions. It's just blindly copying the references inside the list, no?</p>
  
  <p>I'm using Python 2.7.12 on Windows 10.</p>
  
  <p><strong>Edit:</strong> Tried Python 3.5.2 as well now, the results were almost the same (shuffled consistently around 0.17 seconds, unshuffled consistently around 0.05 seconds). Here's the code for that:</p>
  
  <pre><code>a = list(range(10**6))
  random.shuffle(a)
  a = list(a)
  for _ in range(5):
      print(timeit(lambda: list(a), number=10))
  </code></pre>