|
|
|
|
|
by echlebek
3856 days ago
|
|
Once you've exhausted all the low-hanging fruit, like people calling .keys() on dicts, or doing unnecessary linear searches, Cython really starts to shine. I've seen it perform ~40 times better than pure Python in time-consuming loops. We do scientific computing at my company. Numpy does 90% of the work, but there are some algorithms that just aren't easily expressed with arrays. That's where Cython comes in. |
|
Numpy and scipy have been the core of a huge amount of my optimisations. The first question I try and ask is
"Could this be solved with matrix multiplications and summing?"
Often the answer is "yes" and allows you to group a huge amount of calculations all together, and use the heavily optimised code available numpy/scipy.
I recently swapped out something that was running at about 100 rows calculated/second to about half a million in about 0.2s.