Fast version of a heappush followed by a heappop.
(heap, item)
| 162 | return returnitem |
| 163 | |
| 164 | def heappushpop(heap, item): |
| 165 | """Fast version of a heappush followed by a heappop.""" |
| 166 | if heap and heap[0] < item: |
| 167 | item, heap[0] = heap[0], item |
| 168 | _siftup(heap, 0) |
| 169 | return item |
| 170 | |
| 171 | def heapify(x): |
| 172 | """Transform list into a heap, in-place, in O(len(x)) time.""" |