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

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to