I'm in the process of tuning a pet project of mine to improve its performance. I've already busted out the profiler to identify hotspots but I'm thinking understanding Pythons performance characteristics a little better would be quite useful going forward.
There are a few things I'd like to know:
How smart is its optimizer?
Some modern compilers have been blessed with remarkably clever optimisers, that can often take simple code and make it run faster than any human attempts at tuning the code. Depending on how smart the optimizer is, it may be far better for my code to be 'dumb'.
While Python is an 'interpreted' language, it does appear to compile down to some form of bytecode (.pyc). How smart is it when it does this?
- Will it fold constants?
- Will it inline small functions or unroll short loops?
- Will it perform complex data/flow analysis I'm not qualified to explain properly.
How fast are the following operations (comparatively)
- Function calls
- Class instantiation
- Arithmetic
- 'Heavier' math operations such as sqrt()
How are numbers handled internally?
How are numbers stored within Python. Are they stored as integers / floats internally or moved around as a string?
NumPy
How much of a performance difference can NumPy make? This application makes heavy use of Vectors and related mathematics. How much of a difference can be made by using this to accelerate these operations.
Anything else interesting
If you can think of anything else worth knowing, feel free to mention it.
Some background...
Since there are a few people bringing in the 'look at your algorithms first' advice (which is quite sensible advice, but doesn't really help with my purpose in asking this question) I'll add a bit here about whats going on, and why I'm asking about this.
The pet project in