Trivial performance questions

Peter Hansen peter at
Fri Oct 17 15:16:54 CEST 2003

Michael Hudson wrote:
> If profile shows some of this code to be a hotspot, *then* and only
> then is it an appropriate time to worry about such trivial performance
> gains.

And never forget to include the second criterion for bothering to
worry about performance: the code does not meet its performance

Even if profiling shows you a hotspot (as it almost always would),
you are still wasting your time if you don't actually *need* the
code to be faster.  Shaving a few seconds of runtime of a program
that takes a minute to run is likely to be a waste of your time
in the long run, especially when you consider how many times the
program will have to be run to pay back the investment in 
optimization and the resultant increase in maintenance costs.

And remember that use of Python in the first place includes an 
implicit acceptance that performance is not your biggest concern.


More information about the Python-list mailing list