[Tutor] Over optimizing

Kent Johnson kent_johnson at skillsoft.com
Mon Oct 18 20:35:39 CEST 2004


Yes. As a confirmed optimization junkie, I will second that! CAR Hoare 
famously said "Premature optimization is the root of all evil."

For most of the programs mentioned on this list, optimization is not needed 
at all. Once the program is working correctly any performance problems can 
be addressed.

If you do need to improve performance, use a profiler to find the hot 
spots. You will often be surprised at where the time is going!

This page http://c2.com/cgi/wiki?RulesOfOptimization has three rules of 
optimization (and links to other useful info):
1. Don't
2. Don't yet
3. Profile before optimizing.

Kent

At 11:42 AM 10/18/2004 -0600, Mike Hansen wrote:
>[steps up on soapbox]
>
>Lately there's been a lot of talk about getting various code snippets to 
>run faster. It's good to exercise your brain coming up with better ways to 
>optimize code and get exposed to different methods of writing code. I 
>would like to offer a little bit of caution for those new to programming. 
>Many programs run into problems when the the programmer is overly 
>concerned with optimizing. Sometimes inadvertently sacrificing stability 
>and readability in the name of optimization. Sometimes the clever 
>optimization becomes difficult to read and possibly difficult to modify. 
>In general, you should worry about optimizing code only when it appears to 
>be running too slow. Don't try to second guess the program's performance. 
>Machines are pretty fast these days, and are getting faster. In short, get 
>it working, make sure it's readable, and optimize only if it's performing 
>too slow.
>
>Just an opinion based on some books I've read and some experience.
>
>Thanks
>
>[steps off soapbox]
>
>Mike
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list