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
f06c40d6
Commit
f06c40d6
authored
Apr 21, 1998
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filled in some more blanks, with the help of Drew Csillag.
parent
eb2b96b2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
186 additions
and
58 deletions
+186
-58
Doc/api.tex
Doc/api.tex
+93
-29
Doc/api/api.tex
Doc/api/api.tex
+93
-29
No files found.
Doc/api.tex
View file @
f06c40d6
...
...
@@ -980,7 +980,8 @@ check the modules dictionary if there's one there, and if not, create
a new one and insert in in the modules dictionary. Because the former
action is most common, this does not return a new reference, and you
do not own the returned reference. Return
\NULL
{}
with an
exception set on failure.
exception set on failure. NOTE: this function returns
a ``borrowed'' reference.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyImport
_
ExecCodeModule
}{
char *name, PyObject *co
}
...
...
@@ -1697,7 +1698,8 @@ This section describes Python type objects and the singleton object
\label
{
noneObject
}
\begin{cvardesc}
{
PyObject *
}{
Py
_
None
}
XXX macro
The Python
\code
{
None
}
object, denoting lack of value. This object has
no methods.
\end{cvardesc}
...
...
@@ -1753,32 +1755,53 @@ of \var{newpart} appended to \var{string}.
\begin{cfuncdesc}
{
void
}{
PyString
_
ConcatAndDel
}{
PyObject **string,
PyObject *newpart
}
Creates a new string object in
\var
{
*string
}
containing the contents
of
\var
{
newpart
}
appended to
\var
{
string
}
.
--WHAT IS THE
DIFFERENCE BETWEEN THIS AND PLAIN CONCAT?--
of
\var
{
newpart
}
appended to
\var
{
string
}
.
This version decrements
the reference count of
\var
{
newpart
}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{_
PyString
_
Resize
}{
PyObject **string, int newsize
}
A way to resize a string object even though it is ``immutable''.
Only use this to build up a brand new string object; don't use this if
the string may already be known in other parts of the code.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyString
_
Format
}{
PyObject *format,
PyObject *args
}
Returns a new string object from
\var
{
format
}
and
\var
{
args
}
. Analogous
to
\code
{
\var
{
format
}
\%
\var
{
args
}}
. The
\var
{
args
}
argument must be
a tuple.
\end{cfuncdesc}
\begin{cfuncdesc}
{
void
}{
PyString
_
InternInPlace
}{
PyObject **string
}
Intern the argument
\var
{
*string
}
in place. The argument must be the
address of a pointer variable pointing to a Python string object.
If there is an existing interned string that is the same as
\var
{
*string
}
, it sets
\var
{
*string
}
to it (decrementing the reference
count of the old string object and incrementing the reference count of
the interned string object), otherwise it leaves
\var
{
*string
}
alone
and interns it (incrementing its reference count). (Clarification:
even though there is a lot of talk about reference counts, think of
this function as reference-count-neutral; you owned the object after
the call if and only if you own it after the call.)
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyString
_
InternFromString
}{
const char *v
}
A combination of
\code
{
PyString
_
FromString()
}
and
\code
{
PyString
_
InternInPlace()
}
, returning either a new string object
that has been interned, or a new (``owned'') reference to an earlier
interned string object with the same value.
\end{cfuncdesc}
\begin{cfuncdesc}
{
char*
}{
PyString
_
AS
_
STRING
}{
PyObject *string
}
Macro form of
\code
{
PyString
_
AsString
}
but without error checking.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyString
_
GET
_
SIZE
}{
PyObject *string
}
Macro form of
\code
{
PyString
_
GetSize
}
but without error checking.
\end{cfuncdesc}
\subsection
{
Tuple Objects
}
\label
{
tupleObjects
}
...
...
@@ -1806,7 +1829,8 @@ of that tuple.
\begin{cfuncdesc}
{
PyObject*
}{
PyTuple
_
GetItem
}{
PyTupleObject *p, int pos
}
Returns the object at position
\var
{
pos
}
in the tuple pointed
to by
\var
{
p
}
. If
\var
{
pos
}
is out of bounds, returns
\NULL
{}
and
raises an
\exception
{
IndexError
}
exception.
sets an
\exception
{
IndexError
}
exception. NOTE: this function returns
a ``borrowed'' reference.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyTuple
_
GET
_
ITEM
}{
PyTupleObject *p, int pos
}
...
...
@@ -1873,7 +1897,10 @@ Returns the length of the list object in \var{list}.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GetItem
}{
PyObject *list, int index
}
Returns the item in
\var
{
list
}
at index
\var
{
index
}
.
Returns the object at position
\var
{
pos
}
in the list pointed
to by
\var
{
p
}
. If
\var
{
pos
}
is out of bounds, returns
\NULL
{}
and
sets an
\exception
{
IndexError
}
exception. NOTE: this function returns
a ``borrowed'' reference.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
SetItem
}{
PyObject *list, int index,
...
...
@@ -1882,36 +1909,40 @@ Sets the item at index \var{index} in list to \var{item}.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
Insert
}{
PyObject *list, int index,
PyObject *index
}
Inserts the item
\var
{
item
}
into list
\var
{
list
}
in front of index
\var
{
index
}
and returns true if successful.
For example:
\begin{verbatim}
PyList
_
Insert(list, 0, object);
\end{verbatim}
PyObject *item
}
Inserts the item
\var
{
item
}
into list
\var
{
list
}
in front of index
\var
{
index
}
. Returns 0 if successful; returns -1 and sets an
exception if unsuccessful. Analogous to
\code
{
list.insert(index, item)
}
.
\end{cfuncdesc}
would insert
\var
{
object
}
at the front of the list.
\begin{cfuncdesc}
{
int
}{
PyList
_
Append
}{
PyObject *list, PyObject *item
}
Appends the object
\var
{
item
}
at the end of list
\var
{
list
}
.
Appends the object
\var
{
item
}
at the end of list
\var
{
list
}
. Returns
0 if successful; returns -1 and sets an exception if unsuccessful.
Analogous to
\code
{
list.append(item)
}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GetSlice
}{
PyObject *list,
int low, int high
}
Returns a list of the objects in
\var
{
list
}
containing the objects
\emph
{
between
}
\var
{
low
}
and
\var
{
high
}
. Analogous to
\var
{
list[low:high]
}
.
\emph
{
between
}
\var
{
low
}
and
\var
{
high
}
. Returns NULL and sets an
exception if unsuccessful.
Analogous to
\code
{
list[low:high]
}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
SetSlice
}{
PyObject *list,
int low, int high,
PyObject *itemlist
}
Sets the slice of
\var
{
list
}
between
\var
{
low
}
and
\var
{
high
}
to the contents
of
\var
{
itemlist
}
. Analogous to
\code
{
list[low:high]=itemlist
}
. Returns 0
on success, -1 on failure.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
Sort
}{
PyObject *list
}
Sorts the items of
\var
{
list
}
in place. Returns 0 on success, -1 on failure.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
Reverse
}{
PyObject *list
}
Reverses the items of
\var
{
list
}
in place. Returns 0 on success, -1 on failure.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
AsTuple
}{
PyObject *list
}
...
...
@@ -1919,9 +1950,11 @@ Returns a new tuple object containing the contents of \var{list}.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GET
_
ITEM
}{
PyObject *list, int i
}
Macro form of
\code
{
PyList
_
GetItem
}
without error checking.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
GET
_
SIZE
}{
PyObject *list
}
Macro form of
\code
{
PyList
_
GetSize
}
without error checking.
\end{cfuncdesc}
...
...
@@ -1979,29 +2012,31 @@ specified by the \code{char *}\var{key}.
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
GetItem
}{
PyDictObject *p, PyObject *key
}
Returns the object from dictionary
\var
{
p
}
which has a key
\var
{
key
}
. Returns
\NULL
{}
if the key
\var
{
key
}
is not present.
\var
{
key
}
. Returns
\NULL
{}
if the key
\var
{
key
}
is not present, but
without (!) setting an exception. NOTE: this function returns a
``borrowed'' reference.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
GetItemString
}{
PyDictObject *p, char *key
}
Does the same, but
\var
{
key
}
is specified as a
\code
{
char *
}
, rather than a
\code
{
PyObject *
}
.
This is the same as
\code
{
PyDict
_
GetItem()
}
, but
\var
{
key
}
is
specified as a
\code
{
char *
}
, rather than a
\code
{
PyObject *
}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Items
}{
PyDictObject *p
}
Returns a
\code
{
PyListObject
}
containing all the items
from the dictionary, as in the
mapping
method
\method
{
items()
}
(see
from the dictionary, as in the
dictinoary
method
\method
{
items()
}
(see
the
\emph
{
Python Library Reference
}
).
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Keys
}{
PyDictObject *p
}
Returns a
\code
{
PyListObject
}
containing all the keys
from the dictionary, as in the
mapping
method
\method
{
keys()
}
(see the
from the dictionary, as in the
dictionary
method
\method
{
keys()
}
(see the
\emph
{
Python Library Reference
}
).
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Values
}{
PyDictObject *p
}
Returns a
\code
{
PyListObject
}
containing all the values
from the dictionary
\var
{
p
}
, as in the
mapping
method
from the dictionary
\var
{
p
}
, as in the
dictionary
method
\method
{
values()
}
(see the
\emph
{
Python Library Reference
}
).
\end{cfuncdesc}
...
...
@@ -2093,16 +2128,16 @@ Returns a new \code{PyLong} object from the integer part of \var{v}.
\begin{cfuncdesc}
{
long
}{
PyLong
_
AsLong
}{
PyObject *pylong
}
Returns a
\C
{}
\code
{
long
}
representation of the contents of
\var
{
pylong
}
.
WHAT HAPPENS IF
\var
{
pylong
}
> MAXLONG
?
WHAT HAPPENS IF
\var
{
pylong
}
is greater than
\code
{
LONG
_
MAX
}
?
\end{cfuncdesc}
\begin{cfuncdesc}
{
unsigned long
}{
PyLong
_
AsUnsignedLong
}{
PyObject *pylong
}
Returns a
\C
{}
\code
{
unsigned long
}
representation of the contents of
\var
{
pylong
}
. WHAT HAPPENS IF
\var
{
pylong
}
> MAXLONG
?
\var
{
pylong
}
. WHAT HAPPENS IF
\var
{
pylong
}
is greater than
\code
{
ULONG
_
MAX
}
?
\end{cfuncdesc}
\begin{cfuncdesc}
{
double
}{
PyLong
_
AsDouble
}{
PyObject *pylong
}
Returns a
\C
{}
\code
{
double
}
representation of t
eh
contents of
\var
{
pylong
}
.
Returns a
\C
{}
\code
{
double
}
representation of t
he
contents of
\var
{
pylong
}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyLong
_
FromString
}{
char *str, char **pend,
...
...
@@ -2278,8 +2313,37 @@ Writes string \var{s} to file object \var{p}.
\subsection
{
CObjects
}
\label
{
cObjects
}
XXX
\begin{ctypedesc}
{
PyCObject
}
This subtype of
\code
{
PyObject
}
represents an opaque value, useful for
\C
{}
extension modules who need to pass an opaque value (as a
\code
{
void *
}
pointer) through Python code to other
\C
{}
code. It is
often used to make a C function pointer defined in one module
available to other modules, so the regular import mechanism can be
used to access C APIs defined in dynamically loaded modules.
\end{ctypedesc}
\begin{cfuncdesc}
{
PyObject *
}{
PyCObject
_
FromVoidPtr
}{
void* cobj,
void (*destr)(void *)
}
Creates a
\code
{
PyCObject
}
from the
\code
{
void *
}
\var
{
cobj
}
. The
\var
{
destr
}
function will be called when the object is reclaimed.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject *
}{
PyCObject
_
FromVoidPtrAndDesc
}{
void* cobj,
void* desc, void (*destr)(void *, void *)
}
Creates a
\code
{
PyCObject
}
from the
\code
{
void *
}
\var
{
cobj
}
. The
\var
{
destr
}
function will be called when the object is reclaimed. The
\var
{
desc
}
argument
can be used to pass extra callback data for the destructor function.
\end{cfuncdesc}
\begin{cfuncdesc}
{
void *
}{
PyCObject
_
AsVoidPtr
}{
PyObject* self
}
Returns the object
\code
{
void *
}
that the
\code
{
PyCObject
}
\var
{
self
}
was created with.
\end{cfuncdesc}
\begin{cfuncdesc}
{
void *
}{
PyCObject
_
GetDesc
}{
PyObject* self
}
Returns the description
\code
{
void *
}
that the
\code
{
PyCObject
}
\var
{
self
}
was created with.
\end{cfuncdesc}
\chapter
{
Initialization, Finalization, and Threads
}
\label
{
initialization
}
...
...
Doc/api/api.tex
View file @
f06c40d6
...
...
@@ -980,7 +980,8 @@ check the modules dictionary if there's one there, and if not, create
a new one and insert in in the modules dictionary. Because the former
action is most common, this does not return a new reference, and you
do not own the returned reference. Return
\NULL
{}
with an
exception set on failure.
exception set on failure. NOTE: this function returns
a ``borrowed'' reference.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyImport
_
ExecCodeModule
}{
char *name, PyObject *co
}
...
...
@@ -1697,7 +1698,8 @@ This section describes Python type objects and the singleton object
\label
{
noneObject
}
\begin{cvardesc}
{
PyObject *
}{
Py
_
None
}
XXX macro
The Python
\code
{
None
}
object, denoting lack of value. This object has
no methods.
\end{cvardesc}
...
...
@@ -1753,32 +1755,53 @@ of \var{newpart} appended to \var{string}.
\begin{cfuncdesc}
{
void
}{
PyString
_
ConcatAndDel
}{
PyObject **string,
PyObject *newpart
}
Creates a new string object in
\var
{
*string
}
containing the contents
of
\var
{
newpart
}
appended to
\var
{
string
}
.
--WHAT IS THE
DIFFERENCE BETWEEN THIS AND PLAIN CONCAT?--
of
\var
{
newpart
}
appended to
\var
{
string
}
.
This version decrements
the reference count of
\var
{
newpart
}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{_
PyString
_
Resize
}{
PyObject **string, int newsize
}
A way to resize a string object even though it is ``immutable''.
Only use this to build up a brand new string object; don't use this if
the string may already be known in other parts of the code.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyString
_
Format
}{
PyObject *format,
PyObject *args
}
Returns a new string object from
\var
{
format
}
and
\var
{
args
}
. Analogous
to
\code
{
\var
{
format
}
\%
\var
{
args
}}
. The
\var
{
args
}
argument must be
a tuple.
\end{cfuncdesc}
\begin{cfuncdesc}
{
void
}{
PyString
_
InternInPlace
}{
PyObject **string
}
Intern the argument
\var
{
*string
}
in place. The argument must be the
address of a pointer variable pointing to a Python string object.
If there is an existing interned string that is the same as
\var
{
*string
}
, it sets
\var
{
*string
}
to it (decrementing the reference
count of the old string object and incrementing the reference count of
the interned string object), otherwise it leaves
\var
{
*string
}
alone
and interns it (incrementing its reference count). (Clarification:
even though there is a lot of talk about reference counts, think of
this function as reference-count-neutral; you owned the object after
the call if and only if you own it after the call.)
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyString
_
InternFromString
}{
const char *v
}
A combination of
\code
{
PyString
_
FromString()
}
and
\code
{
PyString
_
InternInPlace()
}
, returning either a new string object
that has been interned, or a new (``owned'') reference to an earlier
interned string object with the same value.
\end{cfuncdesc}
\begin{cfuncdesc}
{
char*
}{
PyString
_
AS
_
STRING
}{
PyObject *string
}
Macro form of
\code
{
PyString
_
AsString
}
but without error checking.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyString
_
GET
_
SIZE
}{
PyObject *string
}
Macro form of
\code
{
PyString
_
GetSize
}
but without error checking.
\end{cfuncdesc}
\subsection
{
Tuple Objects
}
\label
{
tupleObjects
}
...
...
@@ -1806,7 +1829,8 @@ of that tuple.
\begin{cfuncdesc}
{
PyObject*
}{
PyTuple
_
GetItem
}{
PyTupleObject *p, int pos
}
Returns the object at position
\var
{
pos
}
in the tuple pointed
to by
\var
{
p
}
. If
\var
{
pos
}
is out of bounds, returns
\NULL
{}
and
raises an
\exception
{
IndexError
}
exception.
sets an
\exception
{
IndexError
}
exception. NOTE: this function returns
a ``borrowed'' reference.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyTuple
_
GET
_
ITEM
}{
PyTupleObject *p, int pos
}
...
...
@@ -1873,7 +1897,10 @@ Returns the length of the list object in \var{list}.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GetItem
}{
PyObject *list, int index
}
Returns the item in
\var
{
list
}
at index
\var
{
index
}
.
Returns the object at position
\var
{
pos
}
in the list pointed
to by
\var
{
p
}
. If
\var
{
pos
}
is out of bounds, returns
\NULL
{}
and
sets an
\exception
{
IndexError
}
exception. NOTE: this function returns
a ``borrowed'' reference.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
SetItem
}{
PyObject *list, int index,
...
...
@@ -1882,36 +1909,40 @@ Sets the item at index \var{index} in list to \var{item}.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
Insert
}{
PyObject *list, int index,
PyObject *index
}
Inserts the item
\var
{
item
}
into list
\var
{
list
}
in front of index
\var
{
index
}
and returns true if successful.
For example:
\begin{verbatim}
PyList
_
Insert(list, 0, object);
\end{verbatim}
PyObject *item
}
Inserts the item
\var
{
item
}
into list
\var
{
list
}
in front of index
\var
{
index
}
. Returns 0 if successful; returns -1 and sets an
exception if unsuccessful. Analogous to
\code
{
list.insert(index, item)
}
.
\end{cfuncdesc}
would insert
\var
{
object
}
at the front of the list.
\begin{cfuncdesc}
{
int
}{
PyList
_
Append
}{
PyObject *list, PyObject *item
}
Appends the object
\var
{
item
}
at the end of list
\var
{
list
}
.
Appends the object
\var
{
item
}
at the end of list
\var
{
list
}
. Returns
0 if successful; returns -1 and sets an exception if unsuccessful.
Analogous to
\code
{
list.append(item)
}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GetSlice
}{
PyObject *list,
int low, int high
}
Returns a list of the objects in
\var
{
list
}
containing the objects
\emph
{
between
}
\var
{
low
}
and
\var
{
high
}
. Analogous to
\var
{
list[low:high]
}
.
\emph
{
between
}
\var
{
low
}
and
\var
{
high
}
. Returns NULL and sets an
exception if unsuccessful.
Analogous to
\code
{
list[low:high]
}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
SetSlice
}{
PyObject *list,
int low, int high,
PyObject *itemlist
}
Sets the slice of
\var
{
list
}
between
\var
{
low
}
and
\var
{
high
}
to the contents
of
\var
{
itemlist
}
. Analogous to
\code
{
list[low:high]=itemlist
}
. Returns 0
on success, -1 on failure.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
Sort
}{
PyObject *list
}
Sorts the items of
\var
{
list
}
in place. Returns 0 on success, -1 on failure.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
Reverse
}{
PyObject *list
}
Reverses the items of
\var
{
list
}
in place. Returns 0 on success, -1 on failure.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
AsTuple
}{
PyObject *list
}
...
...
@@ -1919,9 +1950,11 @@ Returns a new tuple object containing the contents of \var{list}.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GET
_
ITEM
}{
PyObject *list, int i
}
Macro form of
\code
{
PyList
_
GetItem
}
without error checking.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
GET
_
SIZE
}{
PyObject *list
}
Macro form of
\code
{
PyList
_
GetSize
}
without error checking.
\end{cfuncdesc}
...
...
@@ -1979,29 +2012,31 @@ specified by the \code{char *}\var{key}.
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
GetItem
}{
PyDictObject *p, PyObject *key
}
Returns the object from dictionary
\var
{
p
}
which has a key
\var
{
key
}
. Returns
\NULL
{}
if the key
\var
{
key
}
is not present.
\var
{
key
}
. Returns
\NULL
{}
if the key
\var
{
key
}
is not present, but
without (!) setting an exception. NOTE: this function returns a
``borrowed'' reference.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
GetItemString
}{
PyDictObject *p, char *key
}
Does the same, but
\var
{
key
}
is specified as a
\code
{
char *
}
, rather than a
\code
{
PyObject *
}
.
This is the same as
\code
{
PyDict
_
GetItem()
}
, but
\var
{
key
}
is
specified as a
\code
{
char *
}
, rather than a
\code
{
PyObject *
}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Items
}{
PyDictObject *p
}
Returns a
\code
{
PyListObject
}
containing all the items
from the dictionary, as in the
mapping
method
\method
{
items()
}
(see
from the dictionary, as in the
dictinoary
method
\method
{
items()
}
(see
the
\emph
{
Python Library Reference
}
).
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Keys
}{
PyDictObject *p
}
Returns a
\code
{
PyListObject
}
containing all the keys
from the dictionary, as in the
mapping
method
\method
{
keys()
}
(see the
from the dictionary, as in the
dictionary
method
\method
{
keys()
}
(see the
\emph
{
Python Library Reference
}
).
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Values
}{
PyDictObject *p
}
Returns a
\code
{
PyListObject
}
containing all the values
from the dictionary
\var
{
p
}
, as in the
mapping
method
from the dictionary
\var
{
p
}
, as in the
dictionary
method
\method
{
values()
}
(see the
\emph
{
Python Library Reference
}
).
\end{cfuncdesc}
...
...
@@ -2093,16 +2128,16 @@ Returns a new \code{PyLong} object from the integer part of \var{v}.
\begin{cfuncdesc}
{
long
}{
PyLong
_
AsLong
}{
PyObject *pylong
}
Returns a
\C
{}
\code
{
long
}
representation of the contents of
\var
{
pylong
}
.
WHAT HAPPENS IF
\var
{
pylong
}
> MAXLONG
?
WHAT HAPPENS IF
\var
{
pylong
}
is greater than
\code
{
LONG
_
MAX
}
?
\end{cfuncdesc}
\begin{cfuncdesc}
{
unsigned long
}{
PyLong
_
AsUnsignedLong
}{
PyObject *pylong
}
Returns a
\C
{}
\code
{
unsigned long
}
representation of the contents of
\var
{
pylong
}
. WHAT HAPPENS IF
\var
{
pylong
}
> MAXLONG
?
\var
{
pylong
}
. WHAT HAPPENS IF
\var
{
pylong
}
is greater than
\code
{
ULONG
_
MAX
}
?
\end{cfuncdesc}
\begin{cfuncdesc}
{
double
}{
PyLong
_
AsDouble
}{
PyObject *pylong
}
Returns a
\C
{}
\code
{
double
}
representation of t
eh
contents of
\var
{
pylong
}
.
Returns a
\C
{}
\code
{
double
}
representation of t
he
contents of
\var
{
pylong
}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyLong
_
FromString
}{
char *str, char **pend,
...
...
@@ -2278,8 +2313,37 @@ Writes string \var{s} to file object \var{p}.
\subsection
{
CObjects
}
\label
{
cObjects
}
XXX
\begin{ctypedesc}
{
PyCObject
}
This subtype of
\code
{
PyObject
}
represents an opaque value, useful for
\C
{}
extension modules who need to pass an opaque value (as a
\code
{
void *
}
pointer) through Python code to other
\C
{}
code. It is
often used to make a C function pointer defined in one module
available to other modules, so the regular import mechanism can be
used to access C APIs defined in dynamically loaded modules.
\end{ctypedesc}
\begin{cfuncdesc}
{
PyObject *
}{
PyCObject
_
FromVoidPtr
}{
void* cobj,
void (*destr)(void *)
}
Creates a
\code
{
PyCObject
}
from the
\code
{
void *
}
\var
{
cobj
}
. The
\var
{
destr
}
function will be called when the object is reclaimed.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject *
}{
PyCObject
_
FromVoidPtrAndDesc
}{
void* cobj,
void* desc, void (*destr)(void *, void *)
}
Creates a
\code
{
PyCObject
}
from the
\code
{
void *
}
\var
{
cobj
}
. The
\var
{
destr
}
function will be called when the object is reclaimed. The
\var
{
desc
}
argument
can be used to pass extra callback data for the destructor function.
\end{cfuncdesc}
\begin{cfuncdesc}
{
void *
}{
PyCObject
_
AsVoidPtr
}{
PyObject* self
}
Returns the object
\code
{
void *
}
that the
\code
{
PyCObject
}
\var
{
self
}
was created with.
\end{cfuncdesc}
\begin{cfuncdesc}
{
void *
}{
PyCObject
_
GetDesc
}{
PyObject* self
}
Returns the description
\code
{
void *
}
that the
\code
{
PyCObject
}
\var
{
self
}
was created with.
\end{cfuncdesc}
\chapter
{
Initialization, Finalization, and Threads
}
\label
{
initialization
}
...
...
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