Comment #13 on issue 2307 by matt...@gmail.com: Duplicate methods:
as_coeff_mul and as_coeff_Mul
http://code.google.com/p/sympy/issues/detail?id=2307
I got a little lost in the discussion about as_coeff_Mul() due to my recent
duties, but let me comment on a few things. If the test in #11 was to
compare the two methods, then this test is wrong because in [2] and [3] you
get different results. The correct benchmark is this:
In [1]: f = 3*Mul(*symbols('x:100'))
In [2]: %timeit a, b = f.as_coeff_mul(); b = Mul(*b)
10000 loops, best of 3: 149 us per loop
In [3]: %timeit a, b = f.as_coeff_Mul()
100000 loops, best of 3: 14.4 us per loop
(make sure cache is off, because otherwise any benchmarks don't make sense)
I don't mind to have one function for both, but lets understand why this
was introduced at all. The reason is that we very often use naive code
like: a, b = some(expr); (...); _expr = expr.__class__(*b) (well, we really
use Mul and Add explicitly, which makes OO approach a little pointless),
which degenerates performance and readability.
I also think that if the term "coeff" has a well established definition in
Mul, then as_coeff_mul() shouldn't change this without any explanation (it
doesn't even have a docstring). Thus (3.0*x).as_coeff_mul() should return
(3.0, x) (I'm quite convinced that this was the original purpose of this
method).
--
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.