[Python-Dev] Re: heaps

Tim Peters tim.one@comcast.net
Mon, 05 May 2003 20:33:39 -0400


[Raymond Hettinger]
> FWIW, there is C implementation of heapq at:
>    http://zhar.net/projects/python/

Cool!  I thought the code was remarkably clear, until I realized it never
checked for errors (e.g., PyList_Append() can run out of memory, and
PyObject_RichCompareBool() can raise any exception).  Those would have to be
repaired, and doing so would slow it some.

If the heapq module survives with the same API for a release or two, it
would be a fine candidate to move into C, or maybe Pyrex (fiddly little
integer arithmetic interspersed via if/then/else with trivial array indexing
aren't Python's strong suits).