[Python-ideas] priorityqueue, sortedlist in collections?

Adam Olsen rhamph at gmail.com
Fri Mar 2 20:40:32 CET 2007

On 3/2/07, Jim Jewett <jimjjewett at gmail.com> wrote:
> On 3/1/07, Adam Olsen <rhamph at gmail.com> wrote:
> > __iter__ shouldn't modify the container.
> generators do not need to be reiterable.
> lists are reiterable, but I wouldn't expect a socket (treated as a file) to be.
> For a queue that is already sorted, the natural use case is to take
> the task and do it, explicitly adding it back to the end if need be.
> I would expect an operation that *didn't* remove things from the queue
> to have view in the name somewhere.

A priorityqueue seems far more like a list than a socket though.  I'd
be very surprised if __iter__ was destructive.  If destructive is the
only option I would prefer it be a explicit method.  Especially since
it's common modify and reiterate over a priority queue, which I
believe never happens for files or sockets.

Adam Olsen, aka Rhamphoryncus

More information about the Python-ideas mailing list