Comment #25 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
I did a little experimentation with Add and got 10x speedup in this case:
New:
In [1]: L = [ x**i for i in xrange(500) ]
In [2]: %timeit u = sum(L)
10 loops, best of 3: 29.8 ms per loop
In [3]: L = [ x**i for i in xrange(1000) ]
In [4]: %timeit u = sum(L)
10 loops, best of 3: 91.4 ms per loop
Old:
In [1]: L = [ x**i for i in xrange(500) ]
In [2]: %timeit u = sum(L)
1 loops, best of 3: 307 ms per loop
In [3]: L = [ x**i for i in xrange(1000) ]
In [4]: %timeit u = sum(L)
1 loops, best of 3: 1.22 s per loop
The most disturbing thing about Add is the number of function calls it has
to make to flatten inputs. In the case n=1000, in master sum(L) requires
2033969 function calls, which in my branch is reduced this to 29981 (which
can be reduced further). The branch is
https://github.com/mattpap/sympy/tree/speedup, but note that it's far from
being usable.
--
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.