[Tutor] Over optimizing
bill.mill at gmail.com
Mon Oct 18 22:09:33 CEST 2004
as probably the guy you're talking at, I just want to say that I agree
100%. The topic just kind of came up in one thread, but I introduced
it into another. I find that sometimes optimization is fun for its own
sake, and to learn a little bit more about the environment in which
you're programming or operating.
However, as you say, these are treacherous waters. When I write actual
programs, I don't even think about optimization until after the
program's operational, and I can find the bottlenecks in it.
Most likely, the tutor mailing list is not the place for these
discussions. I will try to refrain from them in the future.
bill.mill at gmail.com
On Mon, 18 Oct 2004 14:35:39 -0400, Kent Johnson
<kent_johnson at skillsoft.com> wrote:
> 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.
> 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.
> >[steps off soapbox]
> >Tutor maillist - Tutor at python.org
> Tutor maillist - Tutor at python.org
More information about the Tutor