Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60863
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Subject | Re: how to implement a queue-like container with sort function |
| Date | 2013-12-02 07:26 -0500 |
| References | (1 earlier) <0c445e44-25c7-42b9-8c62-c30428261251@googlegroups.com> <mailman.3400.1385737072.18130.python-list@python.org> <39b48b0b-5c0a-42d9-922f-27987386764b@googlegroups.com> <l7hsk6$n25$1@ger.gmane.org> <CAPTjJmqEBNY+=cqta_ToGrcpGWDyix9y4Jezr9Q=eTpGVq59xw@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3460.1385987179.18130.python-list@python.org> (permalink) |
On 12/2/13 7:04 AM, Chris Angelico wrote: > On Mon, Dec 2, 2013 at 10:58 PM, Ned Batchelder <ned@nedbatchelder.com> wrote: >> Yes, a Queue object has a queue attribute: >> >> >>> import Queue >> >>> q = Queue.Queue() >> >>> q.queue >> deque([]) >> >> But you shouldn't use it. It's part of the implementation of Queue, not >> meant for you to use directly. In particular, if you use it directly, you >> are skipping all synchronization, which is the main reason to use a Queue in >> the first place. > > I should apologize here; when the OP said "queue", I immediately > noticed that I could import that and use it, and mistakenly started my > testing on that, instead of using the deque type. It's deque that > should be used here. Queue is just a wrapper around deque that adds > functionality that has nothing to do with what's needed here. > > ChrisA > Actually, I had a long conversation in the #python IRC channel with the OP at the same time he was posting the question here, and it turns out he knows exactly how many entries are going into the "queue", so a plain-old list is the best solution. I don't know quite where the idea of limiting the number of entries came from. --Ned.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-11-28 17:54 -0800
Re: how to implement a queue-like container with sort function Chris Angelico <rosuav@gmail.com> - 2013-11-29 13:03 +1100
Re: how to implement a queue-like container with sort function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-29 03:32 +0000
Re: how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-11-28 18:04 -0800
Re: how to implement a queue-like container with sort function Chris Angelico <rosuav@gmail.com> - 2013-11-29 13:06 +1100
Re: how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-11-28 18:32 -0800
Re: how to implement a queue-like container with sort function Cameron Simpson <cs@zip.com.au> - 2013-11-29 17:19 +1100
Re: how to implement a queue-like container with sort function MRAB <python@mrabarnett.plus.com> - 2013-11-29 02:23 +0000
Re: how to implement a queue-like container with sort function Terry Reedy <tjreedy@udel.edu> - 2013-11-28 21:31 -0500
Re: how to implement a queue-like container with sort function Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-11-29 17:53 +1300
Re: how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-11-29 04:33 -0800
Re: how to implement a queue-like container with sort function Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-29 14:57 +0000
Re: how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-12-02 03:41 -0800
Re: how to implement a queue-like container with sort function Ned Batchelder <ned@nedbatchelder.com> - 2013-12-02 06:58 -0500
Re: how to implement a queue-like container with sort function Chris Angelico <rosuav@gmail.com> - 2013-12-02 23:04 +1100
Re: how to implement a queue-like container with sort function Ned Batchelder <ned@nedbatchelder.com> - 2013-12-02 07:26 -0500
csiph-web