> Robert, that's not the point. I do have enough Python knowledge to
> understand this (totally trivial) code !-)
>
> What I don't understand is how this code is supposed to save you from
> having to actually write both complex-key-expr and
> expensive-calc-expression more than once. You need them
robert wrote:
> Bruno Desthuilliers wrote:
>> robert wrote:
>>> Bruno Desthuilliers wrote:
robert a écrit :
(snip)
> class MemoCache(dict): # cache expensive Objects during a session
> (memory only)
>def memo(self, k, f):
>try: return self[k]
>excep
Bruno Desthuilliers wrote:
> robert wrote:
>> Bruno Desthuilliers wrote:
>>> robert a écrit :
>>> (snip)
class MemoCache(dict): # cache expensive Objects during a session
(memory only)
def memo(self, k, f):
try: return self[k]
except KeyError:#<
robert wrote:
> Bruno Desthuilliers wrote:
>> robert a écrit :
>> (snip)
>>> class MemoCache(dict): # cache expensive Objects during a session
>>> (memory only)
>>>def memo(self, k, f):
>>>try: return self[k]
>>>except KeyError:#<- was error
>>> re
Bruno Desthuilliers wrote:
> robert a écrit :
> (snip)
>> class MemoCache(dict): # cache expensive Objects during a session
>> (memory only)
>>def memo(self, k, f):
>>try: return self[k]
>>except KeyError:#<- was error
>>return self.setdefault(k
robert a écrit :
(snip)
> class MemoCache(dict): # cache expensive Objects during a session
> (memory only)
>def memo(self, k, f):
>try: return self[k]
>except IndexError:
>return self.setdefault(k, f())
> cache=MemoCache()
> ...
>
> o = cache.memo( complex-key-exp
Mike Kent wrote:
> 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;
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
Gabriel Genellina wrote:
> 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.
>>
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
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=cach
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-
12 matches
Mail list logo