<div dir="ltr"><div dir="ltr">On Wed, Dec 9, 2020 at 4:08 PM Aaron Meurer <<a href="mailto:asmeurer@gmail.com">asmeurer@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, Dec 9, 2020 at 9:41 AM Sebastian Berg<br>
<<a href="mailto:sebastian@sipsolutions.net" target="_blank">sebastian@sipsolutions.net</a>> wrote:<br>
><br>
> On Mon, 2020-12-07 at 14:18 -0700, Aaron Meurer wrote:<br>
> > Regarding np.bool specifically, if you want to deprecate this, you<br>
> > might want to discuss this with us at the array API standard<br>
> > <a href="https://github.com/data-apis/array-api" rel="noreferrer" target="_blank">https://github.com/data-apis/array-api</a> (which is currently in RFC<br>
> > stage). The spec uses bool as the name for the boolean dtype.<br>
> ><br>
> > Would it make sense for NumPy to change np.bool to just be the<br>
> > boolean<br>
> > dtype object? Unlike int and float, there is no ambiguity with bool,<br>
> > and NumPy clearly doesn't have any issues with shadowing builtin<br>
> > names<br>
> > in its namespace.<br>
><br>
> We could keep the Python alias around (which for `dtype=` is the same<br>
> as `np.bool_`).<br>
><br>
> I am not sure I like the idea of immediately shadowing the builtin.<br>
> That is a switch we can avoid flipping (without warning); `np.bool_`<br>
> and `bool` are fairly different beasts? [1]<br>
<br>
NumPy already shadows a lot of builtins, in many cases, in ways that<br>
are incompatible with existing ones. It's not something I would have<br>
done personally, but it's been this way for a long time.<br></blockquote><div><br></div><div>Sometimes, we had the function first before Python added them to the builtins (e.g. sum(), any(), all(), IIRC). I think max() and min() are the main ones that we added after Python did, and we explicitly exclude them from __all__ to avoid clobbering the builtins.</div><div><br></div><div>Shadowing the types (bool, int, float) historically tended to be more problematic than those functions. The first releases of numpy _did_ have those as the scalar types. That empirically turned out to cause more problems for people than sum() or any(), so we renamed the scalar types to have the trailing underscore. We only left the shadowed names as aliases for the builtins because enough people still had `dtype=np.float` in their code that we didn't want to break.</div><div><br></div><div>All that said, "from numpy import *" is less common these days. We have been pretty successful at getting people on board with the np campaign.</div><div> </div></div>-- <br><div dir="ltr" class="gmail_signature">Robert Kern</div></div>