Easier way to save result of a function?

Mike Kent mrmakent at cox.net
Tue Jul 4 19:51:29 EDT 2006


James Mitchelhill wrote:
> Sorry for the clunky subject line - I have a feeling that not knowing
> the proper terms for this is part of my problem.
>
> I'm trying to write a class that analyses some data. I only want it to
> do as much work as necessary, so it saves method results to a
> dictionary, like so:

The term for this is 'memoization'.  You can find several recipes for
this in the online Python Cookbook; for example, see
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/466320




More information about the Python-list mailing list