A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-June/045348.html below:

[Python-Dev] heapq API

[Python-Dev] heapq API [Python-Dev] heapq APIRaymond Hettinger raymond.hettinger at verizon.net
Sat Jun 12 04:38:56 EDT 2004
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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4