All pastes #467239 Raw Edit

Untitled

public python v1 · immutable
·published 2007-05-02 12:23 UTC
rendered paste body
class memoize(object):     def __init__(self, func):        self.func = func        self.mc = EcsCache()    def __call__(self, *args, **kw):        return self._wrap(*args, **kw)    def _wrap(self, *args, **kw):        key = make_key(args, kw, self.func)        cache = self.mc.get(key)        if cache is not None:            return cache        else:            res = self.func(*args, **kw)            self.mc.set(key, res)            return res