[Numpy-discussion] Adding to the non-dispatched implementation of NumPy methods

Stephan Hoyer shoyer at gmail.com
Mon Apr 15 11:30:06 EDT 2019


Hi everyone,

We have a proposed a revision to NEP-18 (__array_function__). The proposal
is for an adding an alias to the non-dispatched version of NumPy array
functions in the __numpy_implementaiton__ function attribute:
https://github.com/numpy/numpy/pull/13305

I believe this attribute improves the protocol in three ways:
1. It provides a hook that __array_function__ methods can use to call
implementation intended for NumPy arrays. This allows for "partial
implementations" of NumPy's API, which turns out to useful even for some
array libraries that reimplement nearly everything (namely, for CuPy and
JAX).
2. It allows for fast access to the non-dispatching version of NumPy
functions, e.g.,
np.concatenate.__numpy_implementation__(list_of_all_numpy_arrays).
3. Internally, the implementation of numpy.ndarray.__array_function__ now
looks identical to how we encourage outside developers to write their own
__array_function__ methods. The dispatching logic no longer includes a
special case for NumPy arrays.

Feedback would be greatly welcomed!

Best,
Stephan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190415/b333cdc8/attachment-0001.html>


More information about the NumPy-Discussion mailing list