Comment #37 on issue 2607 by [email protected]: as_numer_denom() is too slow
http://code.google.com/p/sympy/issues/detail?id=2607

Re #35

right, it doesn't work. Although an entire Mul is cached, when you multiply that by another Mul, all the args are reprocessed. I checked this with Add but the same should apply to Mul:

I put print seq at the start of the flatten routine to see when it is called.

Using + builds up the result one pair at a time
    >>> x+y+z
    [x, y]
    [x + y, z]
    x + y + z
whereas feeding it to Add lets them all be processed at once
    >>> Add(x,y,z)
    [x, y, z]
    x + y + z

The result is cached so repeating the Add won't reflatten the args
    >>> Add(x,y,z)
    x + y + z
    >>> x+y+z
    x + y + z

But if you add something, everything has to be reflattened
    >>> s=_
    >>> s+w
    [x + y + z, w]
    w + x + y + z
    >>> Add(s,v)
    [x + y + z, v]
    v + x + y + z


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