Anton Vredegoor wrote:

> def memoize(fn):
>       cache = {}
>       def proxy(*args):
>           try: return cache[args]
>           except KeyError: return cache.setdefault(args, fn(*args))
>       return proxy

Sorry this doesn't work in this case. This works:

def memoize(fn):
      cache = {}
      def proxy(*args):
          try: return cache[args]
          except KeyError: return cache.setdefault(args, list(fn(*args)))
      return proxy

But then we lose all speed advantages from memoizing so
it's no good either.

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

Reply via email to