sympy/sympy — pull request #716 by smichr (2011-11-15 20:23:59+00:00)
Title: optimize slot 0 operations

Adding or multiplying a Rational onto an Add or Mul should be
very quick. Even though there are core-rewriting work that has
been discussed, having at least the operations with Rationals
be less penalized is an advantage. With these mods, addin a Rational
to an Add or Mul is almost instantaneous for expressions with
30,000 terms/factors; Multiplying a Mul by a Rational is also
fast, but multiplying an Add by a Rational is a bit slower because
of the 2-arg Mul behavior whereby Rationals are distributed on the
terms.