
On Tue, Aug 24, 2021 at 9:50 PM Guido van Rossum <guido@python.org> wrote:
It was pointed out to me that numpy allows arrays that have no elements but a nonzero first dimension. People could disagree about whether that should be considered empty.
indeed -- you can kinda-sorta map an array to nested lists, e.g, is : [[],[],[],[]] an empty list? It has a length of 4, and so does a (4, 0) sized numpy array. numpy is actually mostly consistent with the std lib in that regard.
PS. Why is anyone thinking that an array containing all zeros (and at least one zero) might be considered empty? That seems a totally different kind of test.
I think there may have been confusion with boolean Falsiness indicating emptiness, as it does for Sequences. An array containing all zeros might well be considered False, though not empty. Of course, that's why numpy arrays raise a DeprecationWarning when used that way. Another issue with numpy arrays is that they are non resizable, so needing to check if one is empty is pretty rare -- there is no way that everything could have been removed, or nothing put in in the first place -- the emptiness could have, and likely would have been checked before it was created. -CHB
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...> _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/3FKVLF... Code of Conduct: http://python.org/psf/codeofconduct/
-- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython