Charles R Harris
2016-01-13 05:18:43 UTC
Hi All,
I've opened issue #7002 <https://github.com/numpy/numpy/issues/7002>,
reproduced below, for discussion.
Chuck
I've opened issue #7002 <https://github.com/numpy/numpy/issues/7002>,
reproduced below, for discussion.
Numpy umath has a file scalarmath.c.src that implements scalar arithmetic
using special functions that are about 10x faster than the equivalent
ufuncs.
In [1]: a = np.float64(1)
In [2]: timeit a*a
10000000 loops, best of 3: 69.5 ns per loop
In [3]: timeit np.multiply(a, a)
1000000 loops, best of 3: 722 ns per loop
I contend that in large programs this improvement in execution time is not
worth the complexity and maintenance overhead; it is unlikely that
scalar-scalar arithmetic is a significant part of their execution time.
Therefore I propose to use ufuncs for all of the scalar-scalar arithmetic.
This would also bring the benefits of __numpy_ufunc__ to scalars with
minimal effort.
Thoughts?using special functions that are about 10x faster than the equivalent
ufuncs.
In [1]: a = np.float64(1)
In [2]: timeit a*a
10000000 loops, best of 3: 69.5 ns per loop
In [3]: timeit np.multiply(a, a)
1000000 loops, best of 3: 722 ns per loop
I contend that in large programs this improvement in execution time is not
worth the complexity and maintenance overhead; it is unlikely that
scalar-scalar arithmetic is a significant part of their execution time.
Therefore I propose to use ufuncs for all of the scalar-scalar arithmetic.
This would also bring the benefits of __numpy_ufunc__ to scalars with
minimal effort.
Chuck