Trivial performance questions

Peter Hansen peter at engcorp.com
Fri Oct 17 09:16:54 EDT 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
requirements.

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.

-Peter




More information about the Python-list mailing list