Trivial performance questions

Peter Hansen peter at engcorp.com
Fri Oct 17 14:01:50 EDT 2003


Geoff Gerrietts wrote:
> 
> Maybe I'm a heretic, but I think this is a healthy attitude to have.
> If you can write it optimally the first time with no significant
> increase in effort, then nobody's going to hafta come back and rewrite
> it later: that's a big maintenance win.

Not unless you add Alex' constraint that the two alternatives under
consideration are equally readable.  Otherwise the less readable one
is always going to cost you more at maintenance time.  And I'd add
my own constraint that you actually have to *need* the speed.  Otherwise
even the "insignificant" increase in effort that it will cost you will
not be paying for itself.

  http://c2.com/cgi/wiki?MakeItWorkMakeItRightMakeItFast

Making it right means making it readable too.  Optimization should
always come later, and not at all if you don't actually need it.

My group has invested almost thirty person-years writing Python code in
the last few years.  To the best of my ability to recall, only two of
the tasks we've worked on in that time was directly related to 
performance concerns and the resulting optimization for speed.  Given 
that the combined optimization efforts consumed perhaps a few weeks
of our time, we spend something like 0.4% of our time focusing on 
performance.  This seems to me a healthy amount.

(Curiously enough, when we coded more in C, I suspect we spent a 
substantially larger amount of time caught up in performance issues.
This change is due merely to greater experience, not because of 
the change in language, though the two are related.)

-Peter




More information about the Python-list mailing list