summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-06-20 09:07:53 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-06-20 09:07:53 (GMT)
commit28224f897a1849dd616ad82538bdda45f3351d42 (patch)
tree996268137e0f51ca92d0d5e93a90fae6c482d67f /Doc
parent1761a7cc8b3fffb7c04d81609c705f353eef14a7 (diff)
downloadcpython-28224f897a1849dd616ad82538bdda45f3351d42.zip
cpython-28224f897a1849dd616ad82538bdda45f3351d42.tar.gz
cpython-28224f897a1849dd616ad82538bdda45f3351d42.tar.bz2
Improve the documented advice on how to best use heapq.heapreplace().
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libheapq.tex6
1 files changed, 5 insertions, 1 deletions
diff --git a/Doc/lib/libheapq.tex b/Doc/lib/libheapq.tex
index ffcafcd..edacf79 100644
--- a/Doc/lib/libheapq.tex
+++ b/Doc/lib/libheapq.tex
@@ -59,7 +59,11 @@ If the heap is empty, \exception{IndexError} is raised.
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.
+than \var{item}! That constrains reasonable uses of this routine
+unless written as part of a larger expression:
+\begin{verbatim}
+ result = item <= heap[0] and item or heapreplace(heap, item)
+\end{verbatim}
\end{funcdesc}
Example of use: