sympy/sympy — pull request #1665 by smichr (2012-11-20 12:35:16+00:00)
Title: 3512: watch for Rational in Mul.flatten

I'm not sure why the code was expecting an Integer...the inlines show that it can be a Rational so I just changed the calculation of g. Using gcd is extremely slow; it should be much faster:

```

>>> timeit('gcd(S.Half,S.Half/2)','from sympy import S,gcd',number=1000)0.52889084815979
>>> timeit('S.Half.gcd(S.Half/2)','from sympy import S',number=1000)0.4783451557159424
>>> timeit('Rational(igcd(a.p,b.p),ilcm(a.q,b.q)),S.Half,S.Half/2','from sympy import S,igcd,ilcm,Rational\na=S.Half;b=a/2',number=1000)
0.05117201805114746
```