I have a numpy operation that I call intensively and I need to optimise:
np.sum(a**2, axis=1)**.5 # where a is a 2 dimensional ndarray
This operation is composed of three functions and requires iterating through 'a' three times. It would be more efficient to aggregate all operations under one function and apply that function just once along axis 1. Unfortunately, numpy's apply_along_axis function is not an option as performance is around x1000 worse.
Is there a way of aggregating several numpy operations so it only has to loop once over the array?