range(0, len(a) - 1)
should be more performant of the 2 options. The other makes an unnecessary copy of the sequence (sans 1 element). For looping like this, you might even get a performance boost by using xrange
on python2.x as that avoids materializing a list from the range
call.
Of course, you usually don't need to loop over indices in python -- There's usually a better way.