import numpy as np
x = np.arange(10**5)
for i in xrange(x.size):
foo(x[3000:40000])
and just another version of the code above
import numpy as np
x = np.arange(10**5)
slice_of_x = x[3000:40000]
for i in xrange(x.size):
foo(slice_of_x)
Will the second code be faster or not? I am inclined to think in terms of pointer in C (so that infact the first may be faster) but I understand python is no C.
O.k. This post Slicing a list in Python without generating a copy answers my question.