title: Which gives better performance: len(a[:-1]) or len(a)-1
body: <p>In Python which is better in terms of performance:</p>
  
  <p>1) </p>
  
  <pre><code>for i in range(len(a[:-1])):
      foo()
  </code></pre>
  
  <p>or </p>
  
  <p>2)    </p>
  
  <pre><code>for i in range(len(a)-1):
      foo()
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Some context on why I'm looping over indices (non-idiomatic?):</p>
  
  <pre><code>for c in reversed(range(len(self._N)-1)):
      D[c] =  np.dot(self._W[c], D[c-1])*A[c]*(1-A[c])
  </code></pre>