[Numpy-discussion] NEP: Dispatch Mechanism for NumPy’s high level API

Hameer Abbasi einstein.edison at gmail.com
Mon Jun 4 00:47:15 EDT 2018


Mixed return values of NotImplementedButCoercible and NotImplemented would
still result in TypeError, and there would be no second chances for
overloads.


I would like to differ with you here: It can be quite useful to have second
chances for overloads. Think ``np.func(list, custom_array))``: If second
rounds did not exist, custom_array would need to have a list of coercible
types (which is not nice IMO).

It can also help in cases where performance/feature degradation isn’t an
issue, so coercing all arguments that returned
``NotImplementedButCoercible`` would allow ``__array_function__`` to
succeed where it wouldn’t normally. I mean, that’s one of the major uses of
this sentinel right?

If done in a for loop, it wouldn’t even slow down the nominal cases. It
would have the adverse effect of not allowing for a default implementation
to be as simple as you stated, though.

One thing we could do is manually (inside ``__array_function__``) coerce
anything that didn’t implement ``__array_function__``, and that’s
acceptable to me too.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180603/e292b4ef/attachment-0001.html>


More information about the NumPy-Discussion mailing list