On Fri, Jul 22, 2011 at 10:27 PM, Aaron Meurer <[email protected]> wrote: > On Fri, Jul 22, 2011 at 9:46 AM, Chris Smith <[email protected]> wrote: >> On Thu, Jul 21, 2011 at 2:18 PM, Aaron Meurer <[email protected]> wrote: >>> Perhaps we should implement a keyword argument to subs that would let >>> you do simultaneous substitution (it would basically do the Dummy >>> substitution for you). >>> >>> If you are interested in implementing this, that would be great. We >>> can help you with the details of submitting a patch, etc. >> >> If you are going to encourage modifying subs, it would be nice if we >> could start with a general cleanup of it first...do you think we could >> discuss/modify/push https://github.com/sympy/sympy/pull/234 first? >> >> In my t2 branch I believe 'static' was the word used to control >> whether substitutions were done in series or parallel. I would like to >> move things toward how subs was in t2, but I have not felt encouraged >> to do so since my most modest small changes are stalled in #234 and it >> sounded like you were working on a subs re-write, no? (I wish there >> were a way to know what is in progress.) > > Well, I see this change and the ones that I am suggesting as being > completely separate. This is suggesting adding a new way to handle > multiple substitutions at once. My ideas are strictly about how to do > the individual substitutions (basically, modifications to _eval_subs). > I think that even if the kind of substitutions that I am suggesting > should be implemented using separate functions, that this should still > be an option to subs.
Actually, I see now that this is the wrong approach. subs should be able to do multiple substitutions at once at the core level. The reason is efficiency. Consider the following a = (Add(*(exp(i*x) for i in xrange(1000)))) subslist = [(exp(i*x), t**i) for i in xrange(1000)] a.subs(subslist) # This takes about a minute If you put a print statement print old, new at line 769 of basic.py, you will see why. Each substitution takes some time, and it has to do 1000 of them. If, on the other hand, it could recurse the expression tree only once and do all substitutions at once, I think it would be faster. Indeed, if you try the xreplace function from Ronan's matching branch, which does just this, this returns instantly a.xreplace(dict(subslist)) (see issue 2026) So actually, I'm starting to think that maybe subs should be non-iterative by default. And the internal implementation should be able to handle multiple substitutions at once, not just one at a time. Aaron Meurer > > I have not actually started doing any work yet on subs. Though Ronan > has started with a new function that would do the exact substitution > (see issue 2026). > > By the way, instead of static=True, how about just calling it > iterative=False or something like that? It isn't too important though > (either name would be fine with me). > > Aaron Meurer > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
