peter at engcorp.com
Wed Aug 14 04:42:37 CEST 2002
Andrew Koenig wrote:
> Steve> Seems it would be much easier to go from a function call to
> Steve> inline code than vice versa were such a change to be necessary
> Steve> for optimization reasons. Also much less likely to be
> Steve> inappropriately corrected (since the form you are seeking to
> Steve> optimize will obviously appear in other contexts too).
> I agree. I found it surprising that someone would suggest making such
> wholesale changes after the fact and counting on unit tests to verify
> them all.
To be fair (to me :-), my original suggestion to you was this:
Defining your comparison as such a [sub]routine would certainly be the most
readable and maintainable way to go about it ..., regardless of optimization
issues. Therefore do it that way and don't worry about performance issues yet.
It was only after people continued ignoring this advice and butchered
the code to the point where it no longer worked, all in an attempt to
optimize that which had not been profiled (let alone written and made to work),
that I suggested just getting the thing working first, and refactoring
it later if necessary.
I stand by the latter advice, however, to the extent that if you have
only one or two instances of such a comparison (the maximum you should
have without a subroutine anyway), then refactoring it would be trivial
and *not* likely to be "inappropriately corrected" because of the same
form in other contexts.
Anyway, apparently neither of us would have written the code without
using the subroutine in the first place... some other folks might
still be discussing it rather than writing working code, however. ;-)
More information about the Python-list