summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-02-19 04:08:43 (GMT)
committerRaymond Hettinger <python@rcn.com>2007-02-19 04:08:43 (GMT)
commit00166c5532fc7562c07383a0ae2985b3ffaf253a (patch)
tree6f9c77ecb9639ad781c83d22d63e8014a71d5a76 /Doc/lib
parentd6fc72a5ae27048dae56c773896ccbd6152d9b9b (diff)
downloadcpython-00166c5532fc7562c07383a0ae2985b3ffaf253a.zip
cpython-00166c5532fc7562c07383a0ae2985b3ffaf253a.tar.gz
cpython-00166c5532fc7562c07383a0ae2985b3ffaf253a.tar.bz2
Add merge() function to heapq.
Diffstat (limited to 'Doc/lib')
-rw-r--r--Doc/lib/libheapq.tex15
1 files changed, 13 insertions, 2 deletions
diff --git a/Doc/lib/libheapq.tex b/Doc/lib/libheapq.tex
index 5f3d8c5..32cc25e 100644
--- a/Doc/lib/libheapq.tex
+++ b/Doc/lib/libheapq.tex
@@ -88,7 +88,18 @@ True
>>>
\end{verbatim}
-The module also offers two general purpose functions based on heaps.
+The module also offers three general purpose functions based on heaps.
+
+\begin{funcdesc}{merge}{*iterables}
+Merge multiple sorted inputs into a single sorted output (for example, merge
+timestamped entries from multiple log files). Returns an iterator over
+over the sorted values.
+
+Similar to \code{sorted(itertools.chain(*iterables))} but returns an iterable,
+does not pull the data into memory all at once, and reduces the number of
+comparisons by assuming that each of the input streams is already sorted.
+\versionadded{2.6}
+\end{funcdesc}
\begin{funcdesc}{nlargest}{n, iterable\optional{, key}}
Return a list with the \var{n} largest elements from the dataset defined
@@ -110,7 +121,7 @@ Equivalent to: \samp{sorted(iterable, key=key)[:n]}
\versionchanged[Added the optional \var{key} argument]{2.5}
\end{funcdesc}
-Both functions perform best for smaller values of \var{n}. For larger
+The latter two functions perform best for smaller values of \var{n}. For larger
values, it is more efficient to use the \function{sorted()} function. Also,
when \code{n==1}, it is more efficient to use the builtin \function{min()}
and \function{max()} functions.