diff options
| author | Raymond Hettinger <python@rcn.com> | 2004-06-20 09:07:53 +0000 |
|---|---|---|
| committer | Raymond Hettinger <python@rcn.com> | 2004-06-20 09:07:53 +0000 |
| commit | 28224f897a1849dd616ad82538bdda45f3351d42 (patch) | |
| tree | 996268137e0f51ca92d0d5e93a90fae6c482d67f /Lib/heapq.py | |
| parent | 1761a7cc8b3fffb7c04d81609c705f353eef14a7 (diff) | |
| download | cpython-git-28224f897a1849dd616ad82538bdda45f3351d42.tar.gz | |
Improve the documented advice on how to best use heapq.heapreplace().
Diffstat (limited to 'Lib/heapq.py')
| -rw-r--r-- | Lib/heapq.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/heapq.py b/Lib/heapq.py index 09f996aff8..9fb4e70824 100644 --- a/Lib/heapq.py +++ b/Lib/heapq.py @@ -154,7 +154,9 @@ def heapreplace(heap, item): This is more efficient than heappop() followed by heappush(), and can be more appropriate when using a fixed-size heap. Note that the value returned may be larger than item! That constrains reasonable uses of - this routine. + this routine unless written as part of a larger expression: + + result = item <= heap[0] and item or heapreplace(heap, item) """ returnitem = heap[0] # raises appropriate IndexError if heap is empty heap[0] = item |
