On Sun, 10 Dec 2006 01:53:50 +0100, André Thieme wrote:

> You could maybe give another example: how would one realize something
> like (memoize function) in Python?

By spending thirty seconds googling:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/325205
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/498110

If your needs are very simple, something as simple as this will do it:

def memoize(func):
    def f(arg, _cache={}):
        if _cache.has_key(arg):
            return _cache[arg]
        t = func(arg)
        _cache[arg] = t
        return t
    return f


> Or (defmethod name :after ..)?

I don't even know what that means. Would you like to translate?



-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to