&gt; Numpy does 90% of the work<p>Numpy and scipy have been the core of a huge amount of my optimisations. The first question I try and ask is<p>&quot;Could this be solved with matrix multiplications and summing?&quot;<p>Often the answer is &quot;yes&quot; and allows you to group a huge amount of calculations all together, and use the heavily optimised code available numpy&#x2F;scipy.<p>I recently swapped out something that was running at about 100 rows calculated&#x2F;second to about half a million in about 0.2s.