Please give feedback on two proposed new functions heappushpop(heap,
item) and heapiter(heap). Both are intended to make the API more
closely fit the way heaps are actually used and to take maximum
advantage of the implementation.
The first is equivalent to:
def heappushpop(heap, item):
"Pushes the item onto the heap and then pops the smallest value"
if not heap or item < heap[0]:
return item
return heapreplace(heap, item)
def heapiter(heap):
"Return a destructive iterator over the heap's elements,
smallest-to-largest"
try:
while 1:
yield heappop(heap)
except IndexError:
pass
Raymond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20040612/75c74107/attachment.html