Mercurial > cpython-lru_cache-weakref
diff Doc/lib/libstdtypes.tex @ 13967:7b7ee58901fb legacy-trunk
Document the range type, as suggested by Denis S. Otkidach
<den@analyt.chem.msu.ru>.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Mon, 14 Aug 2000 15:37:59 +0000 |
| parents | 4d14eef8ea07 |
| children | a905c5aa0691 |
line wrap: on
line diff
--- a/Doc/lib/libstdtypes.tex Mon Aug 14 11:29:19 2000 +0000 +++ b/Doc/lib/libstdtypes.tex Mon Aug 14 15:37:59 2000 +0000 @@ -312,8 +312,8 @@ \subsection{Sequence Types \label{typesseq}} -There are five sequence types: strings, Unicode strings, lists, -tuples, and buffers. +There are six sequence types: strings, Unicode strings, lists, +tuples, buffers, and ranges. Strings literals are written in single or double quotes: \code{'xyzzy'}, \code{"frobozz"}. See chapter 2 of the @@ -327,7 +327,10 @@ enclosing parentheses, e.g., \code{a, b, c} or \code{()}. A single item tuple must have a trailing comma, e.g., \code{(d,)}. Buffers are not directly support by Python syntax, but can created by calling the -builtin function \function{buffer()}.\bifuncindex{buffer} +builtin function \function{buffer()}.\bifuncindex{buffer} Ranges are +similar to buffers in that there is no specific syntax to create them, +but they are created using the \function{xrange()} +function.\bifuncindex{xrange} \indexii{sequence}{types} \indexii{string}{type} \indexii{Unicode}{type} @@ -630,10 +633,27 @@ require a sequential parameter list). Additional string operations are defined in standard module -\module{string} and in built-in module \module{re}. +\refmodule{string} and in built-in module \refmodule{re}. \refstmodindex{string} \refstmodindex{re} + +\subsubsection{Range Type \label{typesseq-range}} + +The range\indexii{range}{type} type is an immutable sequence which is +commonly used for looping. The advantage of the range type is that a +range object will always take the same amount of memory, no matter the +size of the range it represents. There are no consistent performance +advantages. + +Range objects behave like tuples, and offer a single method: + +\begin{methoddesc}[range]{tolist}{} + Return a list object which represents the same values as the range + object. +\end{methoddesc} + + \subsubsection{Mutable Sequence Types \label{typesseq-mutable}} List objects support additional operations that allow in-place
