How about letting cacheit be your dictionary? (And I don't see how subs was
going to be used from what you said.)


>>> class aud(object):
...   def __init__(self, func):
...     self.func = func
...   @cacheit
...   def __getitem__(self, arg):
...     return self.func(arg)
...   __call__ = __getitem__
...
>>> def ok(i):
...  t=time()
...  while time()-t<i:pass
...  return i
...
>>> o=aud(ok)
>>> o[2] # takes 2 seconds
2
>>> o[2] # returns immediately
2

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to