4 ms·
I've used Cython for some pretty dramatic results - reducing a run from 1.5 hours to about 20 minutes - but replacing the algorithm with a much more efficient o
by dkersten 17y ago
I've used Cython for some pretty dramatic results - reducing a run from 1.5 hours to about 20 minutes - but replacing the algorithm with a much more efficient one reduced the time down to about 40 seconds, at which point running it through Cython didn't make any difference anymore (and in some cases made it slower). If you are computationally bound and not I/O or data structure bound (my biggest speedup came from exchanging lists for dictionaries to eliminate linear searching - which was a trade-off in accuracy of my algorithms vs speed, but in that specific case it didn't matter) then Cython can give pretty good results. Its also useful for wrapping C libraries.
As is always the case with optimizations, a good algorithm usually goes a lot further than highly optimized, low level code.