Hi all,
TL;DR: Should NumPy add a `like=` to array creation functions? This is an extension of the `__array_function__` protocol useful when working with array-like objects other than NumPy arrays. Including it, effectively means we preliminarily accept NEP 35. Note that without any feedback here, the current default is to include it in the upcoming NumPy 1.20 release. Long Version: Users who only work with NumPy arrays and no alternative array objects are not affected by this (but will see a "useless" keyword argument). However, dask and cupy, asked for the addition of a `like=` keyword argument to array creation functions (list below at [1]) in the proposed NEP 35: https://numpy.org/neps/nep-0035-array-creation-dispatch-with-array-function.html This is an extension of the `__array_function__` protocol. I will refer to the well written NEP for details. It is important to note that there are alternative ideas under consideration [2]. This means there is a chance that the `like=` argument will be superseded by a different solution. My very personal angle currently is this: * Dask/CuPy have shown that this is useful to them * It does not seem like a big burden to me (aside from the new API/documentation which users might get confused by) * We could deprecate it again, even if it may be a slow process. With a lack of a strong argument against it and no clarity when alternatives might become available, I am fine with accepting it into NumPy [3]. However, I can certainly be swayed if anyone has concerns. There are also currently a few small outstanding discussion listed at: https://github.com/numpy/numpy/issues/17075 which is probably too technical for the decision whether or not to include it, but if you are interested in using the feature, lets discuss these as well! Cheers, Sebastian [1] The functions which receive the keyword argument are: * np.array, np.asarray, np.ascontiguousarray, etc. * np.arange * np.ones, np.zeros, np.empty, np.full * np.fromfunction * np.identity * np.fromfile * ... and a few I forgot ... [2] E.g. https://numpy.org/neps/nep-0037-array-module.html [3] There is the "middle ground": We could require an environment variable to activate it. But we discussed it briefly at the community meeting as well, and I think the consensus was there is probably no good argument for that. (e.g. it would mean the argument doesn't show up in the online documentation.) _______________________________________________ NumPy-Discussion mailing list [hidden email] https://mail.python.org/mailman/listinfo/numpy-discussion signature.asc (849 bytes) Download Attachment |
On Thu, Nov 12, 2020, at 17:48, Sebastian Berg wrote:
As long as we don't follow this option (3), I think the changes are innocuous. If it helps some libraries out there, I see no reason not to include it. StÃ©fan _______________________________________________ NumPy-Discussion mailing list [hidden email] https://mail.python.org/mailman/listinfo/numpy-discussion |
Free forum by Nabble | Edit this page |