Python for Finance: Analyze Big Financial Data

(Elle) #1

There is a clear winner: the multithreaded numexpr implementation f6. Its speed


advantage, of course, depends on the number of cores available. The vectorized NumPy


version f4 is slower than f5. The pure Python implementations f1 and f2 are more than


80 times slower than the winner. f3 is the slowest version, since the use of the eval


function for such a large number of evaluations generates a huge overhead. In the case of


numexpr, the string-based expression is evaluated once and then compiled for later use;


with the Python eval function this evaluation takes place 500,000 times.

Free download pdf