title: Python List Slicing Performance
body: <p>I found that the latter was much more efficient (orders of magnitude faster). Is there any reason for this? It was done in Python 2.7.</p>
  
  <pre><code>block = data[y * block_length:y * (block_length + 1)] # Slow
  </code></pre>
  
  <p>vs.</p>
  
  <pre><code>block = [data[y * block_length + z] for z in xrange(block_length)] # Fast
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Using Numpy (this could be the cause), see the code at <a href="http://pastebin.com/88KkWd79" rel="nofollow">http://pastebin.com/88KkWd79</a>
  Run it with time <code>python test.py a</code> or <code>time python test.py b</code>, as the power gets larger, function b begins to take much, much longer.</p>