optimization question

Peter Hansen peter at engcorp.com
Mon Aug 12 05:07:55 CEST 2002


Andrew Koenig wrote:
> 
> Peter> All of which are exactly the reasons to make it *work*, then
> Peter> make it fast.  Starting with s[i:j] == t without any
> Peter> optimization is a fine way to begin...  then refactor when
> Peter> the tests show it's all working perfectly.
> 
> That technique is problematic unless you anticipated that you
> might want to change the code in that way.  Otherwise, by the
> time you have enough of a system to measure, you've written
> s[i:j} == t  in a zillion places throughout the code, and
> replacing them all by function calls is a problem.

Why is it a problem?  Search and replace!

Anyway, if you truly have so many that you can't replace them
easily, it's likely the design is very poor, isn't it?  Why 
would you have so much duplication without already having 
refactored, not for reasons of performance but simply to 
make the code more manageable along the way.

Maybe I'm spoiled by XP and having so many unit tests that
I am willing to refactor aggressively like this without any
qualms...

-Peter



More information about the Python-list mailing list