<div dir="ltr"><div>Sebastian, Stefan and Marten -- thanks for the excellent summaries of the discussion.</div><div><br></div><div>In line with this consensus, I have drafted a revision of the NEP without __skip_array_function__: <a href="https://github.com/numpy/numpy/pull/13624">https://github.com/numpy/numpy/pull/13624</a></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 23, 2019 at 5:28 PM Marten van Kerkwijk <<a href="mailto:m.h.vankerkwijk@gmail.com">m.h.vankerkwijk@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Sebastian, Stéfan,</div><div><br></div><div>Thanks for the very good summaries!</div><div><br></div><div>An additional item worth mentioning is that by using `__skip_array_function__` everywhere inside, one minimizes the performance penalty of checking for `__array_function__`. It would obviously be worth trying to do that, but ideally in a way that is much less intrusive.</div><div><br></div><div>Furthermore, it became clear that there were different pictures of the final goal, with quite a bit of discussion about the relevant benefits of trying the limit exposure of the internal API and of, conversely, trying to (incrementally) move to implementations that are maximally re-usable (using duck-typing), which are themselves based around a smaller core (more in line with Nathaniel's NEP-22).<br></div><div><br></div><div>In the latter respect, Stéfan's example is instructive. The real implementation of `ones_like` is:</div><div>```</div><div>def ones_like(a, dtype=None, order='K', subok=True, shape=None):<br></div><div>    res = empty_like(a, dtype=dtype, order=order, subok=subok, shape=shape)<br>    multiarray.copyto(res, 1, casting='unsafe')<br>    return res</div><div>```</div><div><br></div><div>The first step is here seems obvious: an "empty_like" function would seem to belong in the core.<br></div><div></div><div>The second step less so: Stéfan's `res.fill(1)` seems more logical, as surely a class's method is the optimal way to do something. Though I do feel `.fill` itself breaks "There should be one-- and preferably only one --obvious way to do it." So, I'd want to replace it with `res[...] = 1`, so that one relies on the more obvious `__setitem__`. (Note that all are equally fast even now.)</div><div><br></div><div>Of course, in this idealized future, there would be little reason to even allow `ones_like` to be overridden with __array_function__...</div><div><br></div><div>All the best,</div><div><br></div><div>Marten<br></div></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div>