Comment #24 on issue 2607 by asmeurer: as_numer_denom() is too slow http://code.google.com/p/sympy/issues/detail?id=2607
Would it make sense to pull out the gcd of the denoms?
Well, as I said above, the only way to tell is to construct some expressions and benchmark it. But probably it will be a good idea. Calling cancel() on the resulting expression to remove *all* common factors would be expensive, but I think preprocessing like this would be a cheap way to prevent common factors, thereby significantly reducing the size of the resulting expression (which can only make things faster).
But we should only use terms_gcd instead of gcd (because gcd calls expand(), which would make it slow for things like [(x + 1)**100*(x - 1), ...]). If I remember correctly, you and Mateusz have made terms_gcd pretty fast, right?
By the way, if you look at the non-commutative (A*B**-1 + C*B**-1) as_numer_denom, it's basically a non-commutative terms_gcd. I wonder if all non-commutative cases are like this. At least this could be a simple heuristic.
-- 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.
