3 ms·
K is indeed "naively" implemented. In my experience, its magic is having no magic - everything is straightforwardly simple, the entire interpreter core fits ins
by beagle3 11y ago
K is indeed "naively" implemented. In my experience, its magic is having no magic - everything is straightforwardly simple, the entire interpreter core fits inside the L1 cache, every single operator is doing sequential read/writes and (essentially) blasting through memory at the highest speed.
I've used Matlab ages ago (before they used to JIT), so I can't compare, but I did have a chance to compare K and "straight" Numpy, and for my uses K won by a nontrivial margin (30-40% IIRC) despite using essentially the same solution, and Numpy having comparable implementation -- I guess that's where the cache and memory speed effects come in.
I did venture into using numexpr, which got Numpy a little faster than K, and I would assume Numba and PyPy (neither of which was in existence or usable at the time) might have also helped -- but plain Numpy vs. K was a clear win for K.
It obviously depends on the workload - but I specifically commented about Gorilla - which is a write-a-lot, read-a-little kind of workload, in which K excels and Numpy (as I remember it from 6 years ago) not so much.