Status: Accepted
Owner: asmeurer
Labels: Type-Defect Priority-Medium
New issue 2607 by asmeurer: as_numer_denom() is too slow
http://code.google.com/p/sympy/issues/detail?id=2607
We have
In [5]: a = Add(*[x**i for i in xrange(1000)])
In [4]: %timeit a.as_numer_denom()
1 loops, best of 3: 2.65 s per loop
This is too slow, especially considering that the answer is trivial. The
definition of Add.as_numer_denom() is:
def as_numer_denom(self):
numers, denoms = [],[]
for n,d in [f.as_numer_denom() for f in self.args]:
numers.append(n)
denoms.append(d)
r = xrange(len(numers))
return Add(*[Mul(*(denoms[:i]+[numers[i]]+denoms[i+1:]))
for i in r]), Mul(*denoms)
The time here is all being spend in that last line. Any ideas on how to
make that more efficient?
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.