Hey,
When creating deque instances using a value for maxlen, it would be nice to have a .full() method like what Queue provides, so one may do:
my_deque = deque(maxlen=300)
if my_deque.full(): do_something()
instead of doing:
if len(my_deque) == my_deque.maxlen: do_something()
If people think it's a good idea, I can add a ticket in the tracker and try to provide a patch for the collections module maintainer. If this was already talked about, or is a bad idea, sorry! :)
Cheers Tarek
Isn't the problem that you don't know if it's still full on the next line? After all you supposedly have a multi-threaded app here, otherwise why bother with any of that? Or maybe you can describe the real-world use case where you wanted this in more detail? Without much more evidence I can't support such a change.
On Tue, Oct 11, 2016 at 5:09 AM, Tarek Ziadé tarek@ziade.org wrote:
Hey,
When creating deque instances using a value for maxlen, it would be nice to have a .full() method like what Queue provides, so one may do:
my_deque = deque(maxlen=300)
if my_deque.full(): do_something()
instead of doing:
if len(my_deque) == my_deque.maxlen: do_something()
If people think it's a good idea, I can add a ticket in the tracker and try to provide a patch for the collections module maintainer. If this was already talked about, or is a bad idea, sorry! :)
Cheers Tarek --
Tarek Ziadé | coding: https://ziade.org | running: https://foule.es | twitter: @tarek_ziade _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
Ah! I havn't thought about that because in my use case the deque is append-only so once it's full it discards older elements.
I guess what I really need is a regular FIFO Queue
Thanks for the feedback !