[Tutor] Memoizing ...

Lloyd Kvam pythontutor@venix.com
Wed Jun 18 09:07:02 2003


This is in the Python Cookbook in the Algorithms chapter (17.7).

A Memoize class creates instances that are built to memoize (is this still English?)
the function args and return values.  The args become the dictionary keys and
the function return values are the dictionary values.  The instance tries to return
the values from its dictionary.  If it can't, it calls the original function, adds
to the dictionary, and then returns the function result.

(Page 521 in my copy.)

Gregor Lingl wrote:
> I mean, I'd like to get something like:
> 
>  >>> BINOMM = memoize(BINOM)
> 
> or
> 
>  >>> BINOMM = memoize(BINOM, BINOM.binom)
> 
> or something similar.
> 
> Gregor
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582