Hacker News new | ask | show | jobs
by williamstein 3928 days ago
Sometimes it does. For example if you write a simple O(n) for loop in Python, then convert it to Cython, then compile it, the compiler may replace the for loop by an equivalent O(1) algorithm. I use this to surprise students when benchmarking Cython code for teaching purposes in my SageMath course.
1 comments

If it's just a matter of speeding up a tight loop, I find numba performs admirably and it's a lot more convenient than Cython.

When you need to wrap some c code, or use high-level data structures (that cython handles beautifully with STL integration) that's when it makes sense to drop to Cython.