[Numpy-discussion] Keep __array_function__ unexposed by default for 1.17?

Marten van Kerkwijk m.h.vankerkwijk at gmail.com
Wed May 22 21:00:35 EDT 2019


> If we want to keep an "off" switch we might want to add some sort of API
> for exposing whether NumPy is using __array_function__ or not. Maybe
> numpy.__experimental_array_function_enabled__ = True, so you can just test
> `hasattr(numpy, '__experimental_array_function_enabled__')`? This is
> assuming that we are OK with adding an underscore attribute to NumPy's
> namespace semi-indefinitely.
>

Might this be overthinking it? I might use this myself on supercomputer
runs were I know that I'm using arrays only. Though one should not
extrapolate from oneself!

That said, it is not difficult as is. For instance, we could explain in the
docs that one can tell from:
```
enabled = hasattr(np.core, 'overrides') and
np.core.overrides.ENABLE_ARRAY_FUNCTION
```
One could even allow for eventual removal by explaining it should be,
```
enabled = hasattr(np.core, 'overrides') and getattr(np.core.overrides,
'ENABLE_ARRAY_FUNCTION', True)
```
(If I understand correctly, one cannot tell from the presence of
`ndarray.__array_function__`, correct?)

-- Marten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190522/69fd5516/attachment-0001.html>


More information about the NumPy-Discussion mailing list