Python·100 questions

How to speed up “slow” Python code without rewriting everything?

Answer
Profile first to find hot spots.
Replace algorithms/data structures.
Use built-in functions (they are in C and faster).
Consider NumPy/C packages.
Only then think about Cython/extensions.
Was this answer helpful?

More questions in this topic

Related questions from other topics