Thanks, that was a good example indeed! Improving the memory traffic was actually really important because the real-life application has N=20M+, up to 200M. Around 85M calculations per seconds is pretty impressive I have to say and the example really helps to understand how to write efficient Numba code.
The numba code isn't as pretty as it could be because slicing doesn't work for overlapping memory regions or wraparound indexing yet, and we don't have inlining :(
Here's what I get on a 2.6 GhZ Intel Core i7.
I rewrote your code to minimize memory traffic, then jitted it with numba:
For the case aschreyer is interested in, I see a 24x speedup from half a second to two hundredths of a second. For a really big problem (2 x 10^7), numba is still well under a second and the numpy code is starting to really suffer.My full code is here: https://gist.github.com/ahmadia/5550933
I'm putting it into a wakari notebook so you can actually check me on this :)
Edit 1 - Made the speedup a little more comprehensible (and fixed gist)