good design & method calls

Charles Hartman charles.hartman at conncoll.edu
Tue Mar 29 09:09:37 EST 2005


I know the answer to this is going to be "It depends . . .", but I want 
to get my mind right. In Fowler's *Refactoring* I read: "Older 
languages carried an overhead in subroutine calls, which deterred 
people from small methods" (followed by the basic "Extract Method" 
advice). In Skip Montanaro's "Python Performance Tips" 
(http://manatee.mojam.com/~skip/python/fastpython.html) I read: ". . .  
use local variables wherever possible. If the above loop is cast as a 
function, append and upper become local variables. Python accesses 
local variables much more efficiently than global variables."

These two pieces of advice imply opposite kinds of code revisions. 
Obviously they have different purposes, and both are right at different 
times. I wonder if anyone has some wisdom about how to think about when 
or how often to do which, how to balance them ultimately, and so on.

Charles Hartman
Professor of English, Poet in Residence
the Scandroid is at: http://cherry.conncoll.edu/cohar/Programs
http://villex.blogspot.com




More information about the Python-list mailing list