[Python-Dev] Priority queue (binary heap) python code
Kevin O'Connor
kevin@koconnor.net
Sun, 21 Jul 2002 19:30:57 -0400
On Sat, Jul 20, 2002 at 02:06:29AM -0400, Guido van Rossum wrote:
> > Any chance something like this could make it into the standard python
> > library? It would save a lot of time for lazy people like myself. :-)
> >
>
> I have read (or at least skimmed) this entire thread now. After I
> reconstructed the algorithm in my head, I went back to Kevin's code; I
> admire the compactness of his code. I believe that this would make a
> good addition to the standard library, as a friend of the bisect
> module.
Thanks!
>The only change I would make would be to make heap[0] the
> lowest value rather than the highest.
I agree this appears more natural, but a priority queue that pops the
lowest priority item is a bit odd.
> I propose to call it heapq.py. (Got a better name? Now or never.)
>
> [*] Afterthought: this could be made into an new-style class by adding
> something like this to the end of module:
Looks good to me.
Thanks again,
-Kevin
--
------------------------------------------------------------------------
| Kevin O'Connor "BTW, IMHO we need a FAQ for |
| kevin@koconnor.net 'IMHO', 'FAQ', 'BTW', etc. !" |
------------------------------------------------------------------------