diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2014-09-02 09:00:23 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2014-09-02 09:00:23 -0600 |
commit | 3e31b9a5de6e556b683a39f4d56a1b49e00e4583 (patch) | |
tree | f870e352d9520d6cfa4ed8e68195f4ee91ae8e5d /numpy/lib/polynomial.py | |
parent | 9c50f988ac27dd1758dbc46455573aaa77638c68 (diff) | |
download | numpy-3e31b9a5de6e556b683a39f4d56a1b49e00e4583.tar.gz |
MAINT: Make numpy/lib/polynomial/polyval a bit faster.
Multiplying a numpy_scalar times a numpy_array is much faster than
the other way around. This PR switches the order of multiplication
in the polyval function resulting in a speedup of about 5x for scalar
values of x.
Closes #4610.
Diffstat (limited to 'numpy/lib/polynomial.py')
-rw-r--r-- | numpy/lib/polynomial.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index 6a1adc773..7e4ec1485 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -671,7 +671,7 @@ def polyval(p, x): x = NX.asarray(x) y = NX.zeros_like(x) for i in range(len(p)): - y = x * y + p[i] + y = y * x + p[i] return y def polyadd(a1, a2): |