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

Nathaniel Smith njs at pobox.com
Mon Apr 15 16:20:48 EDT 2019

What's the difference between



np.ndarray.__array_function__(np.concatenate, ...)


More generally, I guess I'm not quite clear on how to think about what the
"no dispatch" version does, because obviously it doesn't make sense to have
*no* dispatch. Instead it's something like "the legacy hard-coded dispatch"?

On Mon, Apr 15, 2019, 08:30 Stephan Hoyer <shoyer at gmail.com> wrote:

> 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
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190415/5323b182/attachment.html>

More information about the NumPy-Discussion mailing list