diff options
author | Fred Drake <fdrake@acm.org> | 2002-04-01 23:02:28 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-04-01 23:02:28 (GMT) |
commit | 7003d5355f01680f37ebd19c4c37c944dc21580b (patch) | |
tree | 8252f4587c256619edb918545291aae9da6b1532 | |
parent | d9ff88d0e0635ddb9f0e40dea45b308b5d337a09 (diff) | |
download | cpython-7003d5355f01680f37ebd19c4c37c944dc21580b.zip cpython-7003d5355f01680f37ebd19c4c37c944dc21580b.tar.gz cpython-7003d5355f01680f37ebd19c4c37c944dc21580b.tar.bz2 |
Fix up the documentation of the type codes to give both the C and Python
types for each code, and give the actual C types.
Document the support for slice operations (back-ported from the trunk) and
note when some TypeError exceptions are raised.
This closes SF bugs 518767 and 536469.
-rw-r--r-- | Doc/lib/libarray.tex | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/Doc/lib/libarray.tex b/Doc/lib/libarray.tex index ac02b87..a357c9b 100644 --- a/Doc/lib/libarray.tex +++ b/Doc/lib/libarray.tex @@ -13,19 +13,19 @@ constrained. The type is specified at object creation time by using a \dfn{type code}, which is a single character. The following type codes are defined: -\begin{tableiii}{c|l|c}{code}{Type code}{C Type}{Minimum size in bytes} -\lineiii{'c'}{character}{1} -\lineiii{'b'}{signed int}{1} -\lineiii{'B'}{unsigned int}{1} -\lineiii{'h'}{signed int}{2} -\lineiii{'H'}{unsigned int}{2} -\lineiii{'i'}{signed int}{2} -\lineiii{'I'}{unsigned int}{2} -\lineiii{'l'}{signed int}{4} -\lineiii{'L'}{unsigned int}{4} -\lineiii{'f'}{float}{4} -\lineiii{'d'}{double}{8} -\end{tableiii} +\begin{tableiv}{c|l|l|c}{code}{Type code}{C Type}{Python Type}{Minimum size in bytes} + \lineiv{'c'}{char} {character} {1} + \lineiv{'b'}{signed char} {int} {1} + \lineiv{'B'}{unsigned char} {int} {1} + \lineiv{'h'}{signed short} {int} {2} + \lineiv{'H'}{unsigned short}{int} {2} + \lineiv{'i'}{signed int} {int} {2} + \lineiv{'I'}{unsigned int} {long} {2} + \lineiv{'l'}{signed long} {int} {4} + \lineiv{'L'}{unsigned long} {long} {4} + \lineiv{'f'}{float} {float} {4} + \lineiv{'d'}{double} {float} {8} +\end{tableiv} The actual representation of values is determined by the machine architecture (strictly speaking, by the C implementation). The actual @@ -51,6 +51,13 @@ Type object corresponding to the objects returned by \end{datadesc} +Array objects support the ordinary sequence operations of +indexing, slicing, concatenation, and multiplication. When using +slice assignment, the assigned value must be an array object with the +same type code; in all other cases, \exception{TypeError} is raised. +Array objects also implement the buffer interface, and may be used +wherever buffer objects are supported. + Array objects support the following data items and methods: \begin{memberdesc}[array]{typecode} @@ -97,7 +104,9 @@ Return the number of occurences of \var{x} in the array. \end{methoddesc} \begin{methoddesc}[array]{extend}{a} -Append array items from \var{a} to the end of the array. +Append array items from \var{a} to the end of the array. The two +arrays must have \emph{exactly} the same type code; if not, +\exception{TypeError} will be raised. \end{methoddesc} \begin{methoddesc}[array]{fromfile}{f, n} |