This is a useful walk through optimization in python.<p>&gt; The lesson is clear: do not write Python code as you would do in C.  Use numpy array operations rather than iterate on arrays.  For me it meant a mental shift.<p>I think the lesson is that &quot;performance critical software requires attention to very many specific details.&quot;  Using a garbage collected language that allocates objects on the heap by default means that you&#x27;ll have to take special steps to change the default behavior of the system.  You will see very similar behavior with C++, Java, etc.<p>&gt;  I didn&#x27;t use Pypy so far because it  only supports part of Numpy, and not Pandas, Scipy, and Sklearn.  It may be that Pypy supports enough of Numpy to run my closest distance code though.  If that&#x27;s the case, then I&#x27;ll blog about it soon.<p>I&#x27;ll confess, I was eagerly waiting the pypy results.  IMO using pypy means I get the best of both worlds: more code that can be naively python with python idioms and still yield sufficient performance.  For critical algorithms where I can&#x27;t hit sufficient performance, it&#x27;s appropriate to use cffi or something to optimize.