Re: We should have an explicit concept of emptiness for collections

Bringing this back on list: On Tue, Aug 24, 2021 at 9:58 PM David Mertz, Ph.D. <david.mertz@gmail.com> wrote:
Sorry, I should have been more explicit. The several kinda of queues can all "contain" items, but do not respond to len().
yeah, I should have looked more closely at your list Though i would consider that an oversight, len(a_queue) could be handy. There is qsize() -- I wonder if there's a reason not to have __len__ do the same thing -- O(n) maybe? See Guido's point that there's an assumption tha len() will be O(1). This is an argument for the OP's point -- there is no standard way to check emptiness. -CHB -- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython

What sort of code would be able to do anything useful with either a sequence or a queue? Queues aren’t iterable. This seems a case of hyper-generalization. On Tue, Aug 24, 2021 at 22:19 Christopher Barker <pythonchb@gmail.com> wrote:
Bringing this back on list:
On Tue, Aug 24, 2021 at 9:58 PM David Mertz, Ph.D. <david.mertz@gmail.com> wrote:
Sorry, I should have been more explicit. The several kinda of queues can all "contain" items, but do not respond to len().
yeah, I should have looked more closely at your list
Though i would consider that an oversight, len(a_queue) could be handy.
There is qsize() -- I wonder if there's a reason not to have __len__ do the same thing -- O(n) maybe? See Guido's point that there's an assumption tha len() will be O(1).
This is an argument for the OP's point -- there is no standard way to check emptiness.
-CHB
-- Christopher Barker, PhD (Chris)
Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython _______________________________________________ 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/EEK7QH... Code of Conduct: http://python.org/psf/codeofconduct/
-- --Guido (mobile)

On 8/24/21 10:26 PM, Guido van Rossum wrote:
On Tue, Aug 24, 2021 at 22:19 Christopher Barker wrote:
On Tue, Aug 24, 2021 at 9:58 PM David Mertz, Ph.D. wrote:
Sorry, I should have been more explicit. The several kinds of queues can all "contain" items, but do not respond to len().
yeah, I should have looked more closely at your list
Though i would consider that an oversight, len(a_queue) could be handy.
There is qsize() -- I wonder if there's a reason not to have __len__ do the same thing -- O(n) maybe? See Guido's point that there's an assumption tha len() will be O(1).
What sort of code would be able to do anything useful with either a sequence or a queue? Queues aren’t iterable. This seems a case of hyper-generalization.
I don't think it's hyper-generalization of queues and sequences, but rather being consistent with the idea of something vs nothing. We can't iterate over integers, but not-zero numbers are still truthy. -- ~Ethan~
participants (3)
-
Christopher Barker
-
Ethan Furman
-
Guido van Rossum