subs is slower and replace/xreplace should be used in places that need
exact matches of sub-expressions or nodes.

There could be pitfalls if the code relies on the features of subs.

Replacing the dummy symbols in linsolve sounds like a job for xreplace, not
subs.

I'm not sure why the matrix class doesn't have an xreplace method. My guess
is we'd accept a pull request that adds one.


Jason
moorepants.info
+01 530-601-9791

On Tue, Nov 17, 2015 at 7:50 PM, Jack Kemp <jack.kemp...@gmail.com> wrote:

> On profiling my code I found it spent a lot of time in subs, particularly
> the subs call at the end of linsolve where it substitutes in your given
> free variables for the dummy parameters from gauss_jordan_solve. If I
> replace subs with xreplace I get a 10x speedup in the substitution process
> (250x without fastcache!).
>
> Are there any possible pitfalls in doing this? My understanding is the
> advantage of subs over xreplace is that it is mathematically aware, so
> (x**4).subs(x**2, y) will yield y**2 for example, while the same would not
> work for xreplace. But if one is always replacing just a free symbol, such
> as replacing the dummy symbol in linsolve, surely the two are equivalent?
> If so, should linsolve just use xreplace?
>
> On the subject, why does the matrix class not have an xreplace method
> which applies xreplace to its elements, like it has for subs?
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/da51f89a-b686-459d-a590-37049e42335d%40googlegroups.com
> <https://groups.google.com/d/msgid/sympy/da51f89a-b686-459d-a590-37049e42335d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAP7f1Agf47sdtH8W-s0VZ6EYXDQrq%2BvJuhfnr%2BcmeE3tt49JOw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to