Comment #29 on issue 683 by [email protected]: speedup of sum(x**i/i,i=1..400)
http://code.google.com/p/sympy/issues/detail?id=683
sum([randint(-2, 2)*x for i in xrange(1000)])
In this case, sum() was much slower than Add() (about 10x), but this was due to naive handling of cancellation (most time was spent in Mul.flatten()). After some tweaking it's only 4x slower. More speed improvement can be obtained by optimizing or removing decorators, etc.
However, I was speaking about something different and comparing sum([x, y, z]) and Add(x, y, z) is useful, but not exactly what I meant. In the code you can very often see thins like a = Add(*args); args = op(args); b = Add(*args), where op() is a trivial or at most simple operation over args, that doesn't imply running full flattening algorithm over args in b = Add(*args). But this is what we do, i.e. we spend a lot of time gathering information and then we immediately lose this information by using args, and this is one important source of speed degradation in SymPy.
There are many other simple yet significant issues. For example, when working on infinities branch, I discovered that Rational(1, 3) - Rational(1, 5) requires a call to Add.flatten(). I don't have say that this is a little in efficient.
-- You received this message because you are subscribed to the Google Groups "sympy-issues" 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-issues?hl=en.
