API, NEP: Inclusion of the experimental `like=` argument in NumPy 1.20 (we currently lean to yes)

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.... 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.)
participants (2)
-
Sebastian Berg
-
Stefan van der Walt