I have a time-consuming function in my project with arguments x, y, and z where z iterates over a big NumPy array Z. I have to call this function lots of times in my project. The first designs that I have used was list comprehension:
output = np.array([my_function(z, x, y) for z in Z])
and the second was map function:
output = np.array(list(map(my_function, Z, repeat(x, len(Z)), repeat(y, len(Z)))))
Unfortunately, I didn’t get much speed up and my code is too slow yet. Is there a more efficient way to do this job?