My python annoyances so far

Steven D'Aprano steve at REMOVEME.cybersource.com.au
Fri Apr 27 00:38:10 EDT 2007


On Thu, 26 Apr 2007 19:36:09 -0700, Alex Martelli wrote:

> Steven D'Aprano <steve at REMOVE.THIS.cybersource.com.au> wrote:
>    ...
>> detail you shouldn't care about. Functions that cache the result of long
>> time-consuming complications are _good_. 
> 
> Not necessarily --

Absolutely -- I didn't mean to imply that functions should _always_ cache
their "complications" (I meant to write calculations, but obviously my
fingers weren't paying attention to my brain).


> <http://blogs.msdn.com/oldnewthing/archive/2004/12/20/327369.aspx>
> asserts the exactly opposite principle, "Don't save anything you can
> recalculate"... of course, the best approach is generally a compromise,
> but it's good to be aware of the potentially high costs of caching:-).

Yes -- I wouldn't cache anything that was cheap enough to calculate. What
cheap enough (in time or memory or other resources) means depends on the
circumstances. Nor would I cache things that were likely to change often.



-- 
Steven D'Aprano 




More information about the Python-list mailing list