efficient memoize decorator?
thattommyhallll@gmail.com
thattommyhall at gmail.com
Sat Aug 19 06:56:43 EDT 2006
does not seem to work for standalone functions, this is a method
decorator only then?
Traceback (most recent call last):
File "prob14memoize.py", line 94, in ?
length = col(i,1)
File "prob14memoize.py", line 49, in __call__
object = self.cache[args] = self.fn(self.instance, *args)
AttributeError: 'Memoize' object has no attribute 'instance'
cheers, tom
Gabriel Genellina wrote:
> At Friday 18/8/2006 17:14, thattommyhallll at gmail.com wrote:
>
> >sorry
> >memoize is
> >http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496879
>
> This implementation uses cPickle to generate a key from the supplied
> function arguments, which is very slow and defeats the purpose of memoizing.
> In your example -function with no keyword arguments- use the much
> simpler implementation from
> <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/325205> NOT
> the original recipe but the comment by Chris Spencer titled "A
> working example".
>
>
>
> Gabriel Genellina
> Softlab SRL
>
>
>
>
>
> __________________________________________________
> Preguntá. Respondé. Descubrí.
> Todo lo que querías saber, y lo que ni imaginabas,
> está en Yahoo! Respuestas (Beta).
> ¡Probalo ya!
> http://www.yahoo.com.ar/respuestas
More information about the Python-list
mailing list