Comment #10 on issue 2607 by asmeurer: as_numer_denom() is too slow
http://code.google.com/p/sympy/issues/detail?id=2607

Ah, it's nice to talk to someone other than myself here :)

Yes, Ronan is exactly right. I carefully split apart the code and profiled it using kernprof/line_profiler (awesome tool, btw), and the bottleneck is line 97 of mul.py, "coeff *= o". In other words, even though it's just multiplying 1 together, it's doing it thousands of times (999001 times to be exact, according to kernprof). If you look at what it's doing, it's computing multiplications duplicate times.

Re benchmarking:  Yes, definitely.

Re preprocessing: I didn't think of this. That would be an additional improvement. I think the sift() function from utilities/iterables.py would be useful here. So, we need to benchmark three cases: all denominators the same (trivial case), all denominators different, and somewhere in between.

By the way, I just realized that when I fixed is_rational_function to be faster at https://github.com/sympy/sympy/pull/382, it was slow because it was using is_numer_denom(). It didn't occur to me then that is_numer_denom() was being too slow. But we should try benchmarking the expresion I used there too, a = Add(*(exp(i*x) for i in range(1000))).

I'll get to this soon, I promise.


--
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.

Reply via email to