conditional computation
Gabriel Genellina
gagsl-py at yahoo.com.ar
Thu Oct 26 16:01:52 EDT 2006
At Thursday 26/10/2006 16:30, robert wrote:
>I want to use a computation cache scheme like
>
>
> o = CACHECOMPUTE complex-key-expr expensive-calc-expr
>
>
>frequently and elegantly without writing complex-key-expr or
>expensive-calc-expr twice.
>So its ugly:
>
> _=complex-key-expr; o=cache.get(_) or
> cache.setdefault(_,expensive-calc-expr)
>
>Any ideas?
The memoize pattern can help; in
http://wiki.python.org/moin/PythonDecoratorLibrary you can see an
implementation using decorators.
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
More information about the Python-list
mailing list