[Numpy-discussion] From Python to Numpy

Matthew Harrigan harrigan.matthew at gmail.com
Fri Jan 13 11:02:47 EST 2017


I coded up an all_equal gufunc here
<https://github.com/mattharrigan/numpy_logical_gufuncs>.  Benchmark results
are also in that repo.  For the specific problem in the book which started
this, its 40x faster than the optimized code in the book.  For large arrays
which have any early non equal element, its dramatically faster (1000x)
than the current alternative.  For large arrays which are all equal, its
~10% faster due to eliminating the intermediate boolean array.  For tiny
arrays its much faster due to a single function call instead of at least
two, but its debatable how relevant speed is for tiny problems.
Disclaimer: this is my first ufunc I have every written.

On Tue, Jan 10, 2017 at 8:27 PM, Chris Barker - NOAA Federal <
chris.barker at noaa.gov> wrote:

> > It seems a generalized ufunc "all_equal" with signature (i),(i)->() and
> short circuit logic once the first non equal element is encountered would
> be an important performance improvement.
>
> How does array_equal() perform?
>
> -CHB
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20170113/0a4d3c19/attachment.html>


More information about the NumPy-Discussion mailing list