[Python-Dev] FIFO data structure?
Agthorr
agthorr@barsoom.org
Sun, 20 Apr 2003 11:30:06 -0700
On Sun, Apr 20, 2003 at 05:16:01AM -0400, Jeremy Fincher wrote:
> 2.3 seems to focus somewhat on adding a wider variety of data structures to
> Python -- well, sets and heapq, at least :) One thing I've found lacking,
> though, is a nice O(1) FIFO queue -- even the standard Queue module
I actually just wrote a modification to Queue that is O(1). There's
no change to the interface, so it doesn't require adding a new data
structure.
I have the code here:
http://www.cs.uoregon.edu/~agthorr/Queue.py
The only changes are near the bottom of the file, beginning with the
_init() function. My implementation uses Python lists, but it uses
them in a smarter way than the existing Queue implementation.
I'll submit a patch to SourceForge in a day or two.
-- Agthorr