Hi, Is there a good reason for ndenumerate in numpy being slower than standard indexing?
For example: --- import numpy as np def fast_itt(a): for index, value in np.ndenumerate(a): a[index] += 1 def slow_itt(a): for r in range(0, a.shape[0]): for c in range(0, a.shape[1]): a[r,c] += 1 a = np.zeros((100,100)) %timeit fast_itt(a) 10 loops, best of 3: 25.7 ms per loop %timeit slow_itt(a) 100 loops, best of 3: 13 ms per loop --- I appreciate that there are better ways of operating on arrays but there are many good reasons for permuting through indices and ndenumerate is a nice way of this... I am left wondering why it performs badly in this case. Cheers, Nathan. _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion