Here I go with my basic questions again, but please bear with me.
In Matlab, is fairly simple to add a number to elements in a list:
a = [1,1,1,1,1]
try this. (I modified the example on the purpose of making it non trivial)
import operator import numpy as np n=10 a = list(range(n)) a1 = [1]*len(a) an = np.array(a)
operator.add is almost more than two times faster
operator.add
%timeit map(operator.add, a, a1)
than adding with numpy
%timeit an+1