[Python-ideas] Adding full() to collections.deque

Tarek Ziadé tarek at ziade.org
Tue Oct 11 12:40:33 EDT 2016


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 !

-- 

Tarek Ziadé | coding: https://ziade.org | running: https://foule.es |
twitter: @tarek_ziade

On Tue, Oct 11, 2016, at 05:44 PM, Guido van Rossum wrote:
> 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 at 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 at python.org
> > https://mail.python.org/mailman/listinfo/python-ideas
> > Code of Conduct: http://python.org/psf/codeofconduct/
> 
> 
> 
> -- 
> --Guido van Rossum (python.org/~guido)


More information about the Python-ideas mailing list