On 04/30/2013 09:26 AM, Chris Smith wrote:
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.
Let a and b be linear combinations of non-commutative symbols (bases)
a = a_{1}e_{1}+...+a_{n}e_{n}
b = b_{1}e_{1}+...+b_{n}e_{n}
Then the product a*b is given by
a*b = expand(a*b).subs(mul_dict)
where the keys of mul_dict are e_{i}*e_{j} and the entries are linear
combinations of the e_{i}'s.
My auto_update_dict would use a function f(e_{i}*e_{j}) to evaluate
e_{i}*e_{j} if e_{i}*e_{j} is not
in the dictionary and add f(e_{i}*e_{j}) to the dictionary.
--
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.