[Python-Dev] heapq API

Armin Rigo arigo at tunes.org
Thu Jun 17 14:03:25 EDT 2004


Hello Raymond,

On Sat, Jun 12, 2004 at 04:38:56AM -0400, Raymond Hettinger wrote:
> def heapiter(heap):
>     "Return a destructive iterator over the heap's elements,
> smallest-to-largest"

Is there a reason why the heap cannot simply be made iterable?
The suggested heapiter() is destructive, but e.g. sys.stdin is also
destructively iterable, so that would not be unprecedented.
Alternatively, would a non-destructive algorithm be significantly slower or
bad for some other reason?


Armin



More information about the Python-Dev mailing list