What is Python good for?

Alex Martelli aleax at aleax.it
Mon Sep 17 04:31:03 EDT 2001


"Delaney, Timothy" <tdelaney at avaya.com> wrote in message
news:mailman.1000687158.25538.python-list at python.org...
    ...
> No one says that optimisation is a bad thing - so long as it is indeed
> optimisation.

"Being indeed optimization" is a necessary but not sufficient
condition for optimization "not being a bad thing".

Optimization that shaves 10% off the running time of a spot
that takes up no more than 5% of the time is probably a bad
thing if it results in program complication (potential for
more bugs, difficulty of maintenance, security weakness): in
most cases that overall 0.5% speedup will not matter much,
but the extra program complication may matter a lot.

Worse, much optimization that IS indeed optimization (and
correctly driven by profiling etc) is local hill-climbing
in performance space.  Maybe you can get a substantial
boost by such hill-climbing -- but there is a very serious
risk that you're missing an "easy" (no-fine-tuning needed)
much taller hill somewhere else.  You may need a very
different program architecture to find the much-taller
hill.  The more complicated your original approach is
made by fine-tuning for optimization, the harder it is
to change things around drastically hunting for the very
tall hills.  Make sure you HAVE played around a lot with
your overall architecture BEFORE you start hill-climbing
(unless, maybe, profiling is telling you that some very
silly operation IS a disproportionate bottleneck -- my
favourite example is Brinch Hansen's original paper on
Concurrent Pascal, where it turned out that by far the
worse bottleneck of the whole compiler was the routine
removing trailing blanks from punched cards read in:-).

The very first essay in "Programming Pearls" should be
mandatory reading for anybody BEFORE they are allowed
to optimize ANYTHING:-).


Alex






More information about the Python-list mailing list