diff options
author | Raymond Hettinger <python@rcn.com> | 2004-09-06 07:04:09 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-09-06 07:04:09 (GMT) |
commit | 8158e849305d0e0ab3e19cdc93a86bb7d5fc0651 (patch) | |
tree | bf2e3439c231960aef92109f2c4f032db1623375 | |
parent | 7d3755d2c0d6d586308666b1dddf185f0169c320 (diff) | |
download | cpython-8158e849305d0e0ab3e19cdc93a86bb7d5fc0651.zip cpython-8158e849305d0e0ab3e19cdc93a86bb7d5fc0651.tar.gz cpython-8158e849305d0e0ab3e19cdc93a86bb7d5fc0651.tar.bz2 |
Fix erroneous docstring comment.
-rw-r--r-- | Doc/lib/libheapq.tex | 5 | ||||
-rw-r--r-- | Lib/heapq.py | 5 | ||||
-rw-r--r-- | Modules/_heapqmodule.c | 5 |
3 files changed, 9 insertions, 6 deletions
diff --git a/Doc/lib/libheapq.tex b/Doc/lib/libheapq.tex index edacf79..55ef641 100644 --- a/Doc/lib/libheapq.tex +++ b/Doc/lib/libheapq.tex @@ -60,9 +60,10 @@ This is more efficient than \function{heappop()} followed by \function{heappush()}, and can be more appropriate when using a fixed-size heap. Note that the value returned may be larger than \var{item}! That constrains reasonable uses of this routine -unless written as part of a larger expression: +unless written as part of a conditional replacement: \begin{verbatim} - result = item <= heap[0] and item or heapreplace(heap, item) + if item > heap[0]: + item = heapreplace(heap, item) \end{verbatim} \end{funcdesc} diff --git a/Lib/heapq.py b/Lib/heapq.py index 9fb4e70..14a00dc 100644 --- a/Lib/heapq.py +++ b/Lib/heapq.py @@ -154,9 +154,10 @@ 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 unless written as part of a larger expression: + this routine unless written as part of a conditional replacement: - result = item <= heap[0] and item or heapreplace(heap, item) + if item > heap[0]: + item = heapreplace(heap, item) """ returnitem = heap[0] # raises appropriate IndexError if heap is empty heap[0] = item diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c index 13e6a3d..192e843 100644 --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -186,8 +186,9 @@ PyDoc_STRVAR(heapreplace_doc, This is more efficient than heappop() followed by heappush(), and can be\n\ more appropriate when using a fixed-size heap. Note that the value\n\ returned may be larger than item! That constrains reasonable uses of\n\ -this routine unless written as part of a larger expression:\n\n\ - result = item <= heap[0] and item or heapreplace(heap, item)\n"); +this routine unless written as part of a conditional replacement:\n\n\ + if item > heap[0]:\n\ + item = heapreplace(heap, item)\n"); static PyObject * heapify(PyObject *self, PyObject *heap) |