Function decorator that caches function results

George Sakkis gsakkis at rutgers.edu
Sat Oct 8 14:37:38 EDT 2005


"Lasse Vågsæther Karlsen" <lasse at vkarlsen.no> wrote:

> [snip]
>
> Ok, so I thought, how about creating a decorator that caches the
> function results and retrieves them from cache if possible, otherwise it
> calls the function and store the value in the cache for the next invokation.
>
> [snip]

Cool, you re-invented the memoization pattern:
http://en.wikipedia.org/wiki/Memoization
http://aspn.activestate.com/ASPN/search?query=memoize&x=0&y=0&section=PYTHONCKBK&type=Subsection

Yes, it's kinda discouraging that most interesting ideas have already been conceived, implemented
and used by others...<wink>

George





More information about the Python-list mailing list