Push item onto heap, maintaining the heap invariant.
(heap, item)
| 131 | 'heappushpop_max', 'nlargest', 'nsmallest', 'merge'] |
| 132 | |
| 133 | def heappush(heap, item): |
| 134 | """Push item onto heap, maintaining the heap invariant.""" |
| 135 | heap.append(item) |
| 136 | _siftdown(heap, 0, len(heap)-1) |
| 137 | |
| 138 | def heappop(heap): |
| 139 | """Pop the smallest item off the heap, maintaining the heap invariant.""" |