Add/Mul -- introduce ._new_rawargs()
To create new instance of own class with args exactly as provided by caller
This is handy when we want to optimize things, e.g.
>>> from sympy import Mul, symbols
>>> x,y = symbols('xy')
>>> e = Mul(3,x,y)
>>> e.args
(3, x, y)
>>> Mul(*e.args[1:])
x*y
>>> e._new_rawargs(*e.args[1:]) # the same as above, but faster
x*y
Timings (cache: off)
--------------------
%timeit %timeit
Mul(*e.args[1:]) e._new_rawargs(*e.args[1:])
204 µs 25.7 µs
We'll use this nice new function to optimize Add(*looong_seq) in the next patch.
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Ondrej Certik <ondrej@certik.cz>