How do I speed up profiled NumPy code - vectorizing, Numba?
问题 I am running a large Python program to optimize portfolio weights for (Markowitz) portfolio optimization in finance. When I Profile the code, 90% of the run time is spent calculating the portfolio return, which is done millions of times. What can I do to speed up my code? I have tried: vectorizing the calculation of returns: made the code slower , from 1.5 ms to 3 ms used the function autojit from Numba to speed up the code: no change See example below - any suggestions? import numpy as np