[Numpy-discussion] Why are empty arrays False?
pav at iki.fi
Sat Aug 19 09:22:33 EDT 2017
Michael Lamparski kirjoitti 19.08.2017 klo 07:04:
>> I'd be tentatively in favor of deprecating bool(array() with a
> warning asking for `.squeeze()` to be used, since this also hides a
> (smaller) class of bugs.
> I can get behind this as well, though I just keep wondering in the back
> of my mind whether there's some tricky but legitimate use case that I'm
> not thinking about, where arrays of size 1 just happen to have a natural
> tendency to arise.
Changing this sort of fundamental semantics (i.e. size-1 arrays behave
like scalars in bool, int, etc. casting context) this late in the game
in my opinion should be discussed with more care.
While the intention of making it harder to write code with bugs is good,
it should not come at the cost of having everyone fix their old scripts,
which worked correctly previously, but then suddenly stop working. Note
also that I expect polling on this mailing list will not reach the
majority of the user base, so I would suggest being very conservative
when deprecating features that are not wrong but only with suboptimal
semantics. This sort of backward-incompatible changes accumulate, and
will lead to rotting of third-party code.
More information about the NumPy-Discussion