Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8a135252
Commit
8a135252
authored
Feb 27, 1998
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates by AMK.
Markup corrected, logical markup.
parent
4f56f2d6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
26 deletions
+78
-26
Doc/lib/libarray.tex
Doc/lib/libarray.tex
+39
-13
Doc/libarray.tex
Doc/libarray.tex
+39
-13
No files found.
Doc/lib/libarray.tex
View file @
8a135252
...
...
@@ -10,7 +10,7 @@ except that the type of objects stored in them is 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|c|c|
}{
code
}{
Type
code
}{
Type
}{
Minimal
size in bytes
}
\begin{tableiii}
{
|c|c|c|
}{
code
}{
Type
code
}{
Type
}{
Minimum
size in bytes
}
\lineiii
{
'c'
}{
character
}{
1
}
\lineiii
{
'b'
}{
signed integer
}{
1
}
\lineiii
{
'B'
}{
unsigned integer
}{
1
}
...
...
@@ -25,29 +25,28 @@ which is a single character. The following type codes are defined:
\end{tableiii}
The actual representation of values is determined by the machine
architecture (strictly speaking, by the
C
implementation). The actual
architecture (strictly speaking, by the
\C
{}
implementation). The actual
size can be accessed through the
\var
{
itemsize
}
attribute. The values
stored for
\code
{
'L'
}
and
\code
{
'I'
}
items will be represented as
Python long integers when retrieved, because Python's plain integer
type can't represent the full range of
C
's unsigned (long) integers.
type can't represent the full range of
\C
{}
's unsigned (long) integers.
See also built-in module
\code
{
struct
}
.
\refbimodindex
{
struct
}
See also built-in module
\module
{
struct
}
\refbimodindex
{
struct
}
.
The module defines the following function:
\setindexsubitem
{
(in module array)
}
\begin{funcdesc}
{
array
}{
typecode
\optional
{
\,
initializer
}}
Return a new array whose items are restricted by
\var
{
typecode
}
, and
initialized from the optional
\var
{
initializer
}
value, which must be a
list or a string. The list or string is passed to the new array's
\
code
{
fromlist()
}
or
\code
{
fromstring()
}
method (see below) to add
\
method
{
fromlist()
}
or
\method
{
fromstring()
}
method (see below) to add
initial items to the array.
\end{funcdesc}
Array objects support the following data items and methods:
\setindexsubitem
{
(array attribute)
}
\begin{datadesc}
{
typecode
}
The typecode character used to create the array.
\end{datadesc}
...
...
@@ -56,6 +55,8 @@ The typecode character used to create the array.
The length in bytes of one array item in the internal representation.
\end{datadesc}
\setindexsubitem
{
(array method)
}
\begin{funcdesc}
{
append
}{
x
}
Append a new item with value
\var
{
x
}
to the end of the array.
\end{funcdesc}
...
...
@@ -65,7 +66,7 @@ Return a tuple \code{(\var{address}, \var{length})} giving the current
memory address and the length in bytes of the buffer used to hold
array's contents. This is occasionally useful when working with
low-level (and inherently unsafe) I/O interfaces that require memory
addresses, such as certain
\c
ode
{
ioctl
}
operations. The returned
addresses, such as certain
\c
function
{
ioctl()
}
operations. The returned
numbers are valid as long as the array exists and no length-changing
operations are applied to it.
\end{funcdesc}
...
...
@@ -79,22 +80,24 @@ on a machine with a different byte order.
\begin{funcdesc}
{
fromfile
}{
f
\,
n
}
Read
\var
{
n
}
items (as machine values) from the file object
\var
{
f
}
and append them to the end of the array. If less than
\var
{
n
}
items
are available,
\
code
{
EOFError
}
is raised, but the items that were
are available,
\
exception
{
EOFError
}
is raised, but the items that were
available are still inserted into the array.
\var
{
f
}
must be a real
built-in file object; something else with a
\code
{
read()
}
method won't
do.
Also available as the
\method
{
read()
}
method.
\end{funcdesc}
\begin{funcdesc}
{
fromlist
}{
list
}
Append items from the list. This is equivalent to
\
code
{
for x in
\var
{
list
}
:
\
a.append(x)
}
\
samp
{
for x in
\var
{
list
}
:
\
a.append(x)
}
except that if there is a type error, the array is unchanged.
\end{funcdesc}
\begin{funcdesc}
{
fromstring
}{
s
}
Appends items from the string, interpreting the string as an
array of machine values (i.e. as if it had been read from a
file using the
\
code
{
fromfile()
}
method).
file using the
\
method
{
fromfile()
}
method).
\end{funcdesc}
\begin{funcdesc}
{
insert
}{
i
\,
x
}
...
...
@@ -102,8 +105,25 @@ Insert a new item with value \var{x} in the array before position
\var
{
i
}
.
\end{funcdesc}
\begin{funcdesc}
{
read
}{
f
\,
n
}
Read
\var
{
n
}
items (as machine values) from the file object
\var
{
f
}
and append them to the end of the array. If less than
\var
{
n
}
items
are available,
\exception
{
EOFError
}
is raised, but the items that were
available are still inserted into the array.
\var
{
f
}
must be a real
built-in file object; something else with a
\method
{
read()
}
method won't
do.
Also available as the
\method
{
fromfile()
}
method.
\end{funcdesc}
\begin{funcdesc}
{
reverse
}{}
Reverse the order of the items in the array.
\end{funcdesc}
\begin{funcdesc}
{
tofile
}{
f
}
Write all items (as machine values) to the file object
\var
{
f
}
.
Also available as the
\function
{
write()
}
function.
\end{funcdesc}
\begin{funcdesc}
{
tolist
}{}
...
...
@@ -113,7 +133,13 @@ Convert the array to an ordinary list with the same items.
\begin{funcdesc}
{
tostring
}{}
Convert the array to an array of machine values and return the
string representation (the same sequence of bytes that would
be written to a file by the
\code
{
tofile()
}
method.)
be written to a file by the
\method
{
tofile()
}
method.)
\end{funcdesc}
\begin{funcdesc}
{
write
}{
f
}
Write all items (as machine values) to the file object
\var
{
f
}
.
Also available as the
\function
{
write()
}
function.
\end{funcdesc}
When an array object is printed or converted to a string, it is
...
...
Doc/libarray.tex
View file @
8a135252
...
...
@@ -10,7 +10,7 @@ except that the type of objects stored in them is 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|c|c|
}{
code
}{
Type
code
}{
Type
}{
Minimal
size in bytes
}
\begin{tableiii}
{
|c|c|c|
}{
code
}{
Type
code
}{
Type
}{
Minimum
size in bytes
}
\lineiii
{
'c'
}{
character
}{
1
}
\lineiii
{
'b'
}{
signed integer
}{
1
}
\lineiii
{
'B'
}{
unsigned integer
}{
1
}
...
...
@@ -25,29 +25,28 @@ which is a single character. The following type codes are defined:
\end{tableiii}
The actual representation of values is determined by the machine
architecture (strictly speaking, by the
C
implementation). The actual
architecture (strictly speaking, by the
\C
{}
implementation). The actual
size can be accessed through the
\var
{
itemsize
}
attribute. The values
stored for
\code
{
'L'
}
and
\code
{
'I'
}
items will be represented as
Python long integers when retrieved, because Python's plain integer
type can't represent the full range of
C
's unsigned (long) integers.
type can't represent the full range of
\C
{}
's unsigned (long) integers.
See also built-in module
\code
{
struct
}
.
\refbimodindex
{
struct
}
See also built-in module
\module
{
struct
}
\refbimodindex
{
struct
}
.
The module defines the following function:
\setindexsubitem
{
(in module array)
}
\begin{funcdesc}
{
array
}{
typecode
\optional
{
\,
initializer
}}
Return a new array whose items are restricted by
\var
{
typecode
}
, and
initialized from the optional
\var
{
initializer
}
value, which must be a
list or a string. The list or string is passed to the new array's
\
code
{
fromlist()
}
or
\code
{
fromstring()
}
method (see below) to add
\
method
{
fromlist()
}
or
\method
{
fromstring()
}
method (see below) to add
initial items to the array.
\end{funcdesc}
Array objects support the following data items and methods:
\setindexsubitem
{
(array attribute)
}
\begin{datadesc}
{
typecode
}
The typecode character used to create the array.
\end{datadesc}
...
...
@@ -56,6 +55,8 @@ The typecode character used to create the array.
The length in bytes of one array item in the internal representation.
\end{datadesc}
\setindexsubitem
{
(array method)
}
\begin{funcdesc}
{
append
}{
x
}
Append a new item with value
\var
{
x
}
to the end of the array.
\end{funcdesc}
...
...
@@ -65,7 +66,7 @@ Return a tuple \code{(\var{address}, \var{length})} giving the current
memory address and the length in bytes of the buffer used to hold
array's contents. This is occasionally useful when working with
low-level (and inherently unsafe) I/O interfaces that require memory
addresses, such as certain
\c
ode
{
ioctl
}
operations. The returned
addresses, such as certain
\c
function
{
ioctl()
}
operations. The returned
numbers are valid as long as the array exists and no length-changing
operations are applied to it.
\end{funcdesc}
...
...
@@ -79,22 +80,24 @@ on a machine with a different byte order.
\begin{funcdesc}
{
fromfile
}{
f
\,
n
}
Read
\var
{
n
}
items (as machine values) from the file object
\var
{
f
}
and append them to the end of the array. If less than
\var
{
n
}
items
are available,
\
code
{
EOFError
}
is raised, but the items that were
are available,
\
exception
{
EOFError
}
is raised, but the items that were
available are still inserted into the array.
\var
{
f
}
must be a real
built-in file object; something else with a
\code
{
read()
}
method won't
do.
Also available as the
\method
{
read()
}
method.
\end{funcdesc}
\begin{funcdesc}
{
fromlist
}{
list
}
Append items from the list. This is equivalent to
\
code
{
for x in
\var
{
list
}
:
\
a.append(x)
}
\
samp
{
for x in
\var
{
list
}
:
\
a.append(x)
}
except that if there is a type error, the array is unchanged.
\end{funcdesc}
\begin{funcdesc}
{
fromstring
}{
s
}
Appends items from the string, interpreting the string as an
array of machine values (i.e. as if it had been read from a
file using the
\
code
{
fromfile()
}
method).
file using the
\
method
{
fromfile()
}
method).
\end{funcdesc}
\begin{funcdesc}
{
insert
}{
i
\,
x
}
...
...
@@ -102,8 +105,25 @@ Insert a new item with value \var{x} in the array before position
\var
{
i
}
.
\end{funcdesc}
\begin{funcdesc}
{
read
}{
f
\,
n
}
Read
\var
{
n
}
items (as machine values) from the file object
\var
{
f
}
and append them to the end of the array. If less than
\var
{
n
}
items
are available,
\exception
{
EOFError
}
is raised, but the items that were
available are still inserted into the array.
\var
{
f
}
must be a real
built-in file object; something else with a
\method
{
read()
}
method won't
do.
Also available as the
\method
{
fromfile()
}
method.
\end{funcdesc}
\begin{funcdesc}
{
reverse
}{}
Reverse the order of the items in the array.
\end{funcdesc}
\begin{funcdesc}
{
tofile
}{
f
}
Write all items (as machine values) to the file object
\var
{
f
}
.
Also available as the
\function
{
write()
}
function.
\end{funcdesc}
\begin{funcdesc}
{
tolist
}{}
...
...
@@ -113,7 +133,13 @@ Convert the array to an ordinary list with the same items.
\begin{funcdesc}
{
tostring
}{}
Convert the array to an array of machine values and return the
string representation (the same sequence of bytes that would
be written to a file by the
\code
{
tofile()
}
method.)
be written to a file by the
\method
{
tofile()
}
method.)
\end{funcdesc}
\begin{funcdesc}
{
write
}{
f
}
Write all items (as machine values) to the file object
\var
{
f
}
.
Also available as the
\function
{
write()
}
function.
\end{funcdesc}
When an array object is printed or converted to a string, it is
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment