[Numpy-discussion] Get rid of special scalar arithmetic

Charles R Harris charlesr.harris at gmail.com
Wed Jan 13 00:18:43 EST 2016


Hi All,

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?

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160112/326c49c9/attachment.html>


More information about the NumPy-Discussion mailing list