[Python-checkins] python/dist/src/Doc/lib libheapq.tex,1.10,1.11

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Thu Dec 2 09:59:16 CET 2004


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20862/Doc/lib
Modified Files:
	libheapq.tex 
Log Message:
Add key= argument to heapq.nsmallest() and heapq.nlargest().
Index: libheapq.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libheapq.tex,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- libheapq.tex	6 Sep 2004 07:04:09 -0000	1.10
+++ libheapq.tex	2 Dec 2004 08:59:13 -0000	1.11
@@ -90,16 +90,24 @@
 
 The module also offers two general purpose functions based on heaps.
 
-\begin{funcdesc}{nlargest}{n, iterable}
+\begin{funcdesc}{nlargest}{n, iterable\optional{, key}}
 Return a list with the \var{n} largest elements from the dataset defined
-by \var{iterable}. Equivalent to: \code{sorted(iterable, reverse=True)[:n]}
-\versionadded{2.4} 
+by \var{iterable}. \var{key}, if provided, specifies a function of one
+argument that is used to extract a comparison key from each element
+in the iterable: \samp{\var{key}=\function{str.lower}}
+Equivalent to: \samp{sorted(iterable, key=key, reverse=True)[:n]}
+\versionadded{2.4}
+\versionchanged[Added the optional \var{key} argument]{2.5}
 \end{funcdesc}
 
-\begin{funcdesc}{nsmallest}{n, iterable}
+\begin{funcdesc}{nsmallest}{n, iterable\optional{, key}}
 Return a list with the \var{n} smallest elements from the dataset defined
-by \var{iterable}. Equivalent to: \code{sorted(iterable)[:n]}
-\versionadded{2.4} 
+by \var{iterable}. \var{key}, if provided, specifies a function of one
+argument that is used to extract a comparison key from each element
+in the iterable: \samp{\var{key}=\function{str.lower}}
+Equivalent to: \samp{sorted(iterable, key=key)[:n]}
+\versionadded{2.4}
+\versionchanged[Added the optional \var{key} argument]{2.5}
 \end{funcdesc}
 
 Both functions perform best for smaller values of \var{n}. For larger


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /