Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
4447513e
Kaydet (Commit)
4447513e
authored
Nis 21, 1998
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Filled in some more blanks, with the help of Drew Csillag.
üst
955a2f53
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
186 additions
and
58 deletions
+186
-58
api.tex
Doc/api.tex
+93
-29
api.tex
Doc/api/api.tex
+93
-29
No files found.
Doc/api.tex
Dosyayı görüntüle @
4447513e
...
@@ -980,7 +980,8 @@ check the modules dictionary if there's one there, and if not, create
...
@@ -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
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
action is most common, this does not return a new reference, and you
do not own the returned reference. Return
\NULL
{}
with an
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyImport
_
ExecCodeModule
}{
char *name, PyObject *co
}
\begin{cfuncdesc}
{
PyObject*
}{
PyImport
_
ExecCodeModule
}{
char *name, PyObject *co
}
...
@@ -1697,7 +1698,8 @@ This section describes Python type objects and the singleton object
...
@@ -1697,7 +1698,8 @@ This section describes Python type objects and the singleton object
\label
{
noneObject
}
\label
{
noneObject
}
\begin{cvardesc}
{
PyObject *
}{
Py
_
None
}
\begin{cvardesc}
{
PyObject *
}{
Py
_
None
}
XXX macro
The Python
\code
{
None
}
object, denoting lack of value. This object has
no methods.
\end{cvardesc}
\end{cvardesc}
...
@@ -1753,32 +1755,53 @@ of \var{newpart} appended to \var{string}.
...
@@ -1753,32 +1755,53 @@ of \var{newpart} appended to \var{string}.
\begin{cfuncdesc}
{
void
}{
PyString
_
ConcatAndDel
}{
PyObject **string,
\begin{cfuncdesc}
{
void
}{
PyString
_
ConcatAndDel
}{
PyObject **string,
PyObject *newpart
}
PyObject *newpart
}
Creates a new string object in
\var
{
*string
}
containing the contents
Creates a new string object in
\var
{
*string
}
containing the contents
of
\var
{
newpart
}
appended to
\var
{
string
}
.
--WHAT IS THE
of
\var
{
newpart
}
appended to
\var
{
string
}
.
This version decrements
DIFFERENCE BETWEEN THIS AND PLAIN CONCAT?--
the reference count of
\var
{
newpart
}
.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{_
PyString
_
Resize
}{
PyObject **string, int newsize
}
\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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyString
_
Format
}{
PyObject *format,
\begin{cfuncdesc}
{
PyObject*
}{
PyString
_
Format
}{
PyObject *format,
PyObject *args
}
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
void
}{
PyString
_
InternInPlace
}{
PyObject **string
}
\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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyString
_
InternFromString
}{
const char *v
}
\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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
char*
}{
PyString
_
AS
_
STRING
}{
PyObject *string
}
\begin{cfuncdesc}
{
char*
}{
PyString
_
AS
_
STRING
}{
PyObject *string
}
Macro form of
\code
{
PyString
_
AsString
}
but without error checking.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyString
_
GET
_
SIZE
}{
PyObject *string
}
\begin{cfuncdesc}
{
int
}{
PyString
_
GET
_
SIZE
}{
PyObject *string
}
Macro form of
\code
{
PyString
_
GetSize
}
but without error checking.
\end{cfuncdesc}
\end{cfuncdesc}
\subsection
{
Tuple Objects
}
\subsection
{
Tuple Objects
}
\label
{
tupleObjects
}
\label
{
tupleObjects
}
...
@@ -1806,7 +1829,8 @@ of that tuple.
...
@@ -1806,7 +1829,8 @@ of that tuple.
\begin{cfuncdesc}
{
PyObject*
}{
PyTuple
_
GetItem
}{
PyTupleObject *p, int pos
}
\begin{cfuncdesc}
{
PyObject*
}{
PyTuple
_
GetItem
}{
PyTupleObject *p, int pos
}
Returns the object at position
\var
{
pos
}
in the tuple pointed
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
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyTuple
_
GET
_
ITEM
}{
PyTupleObject *p, int pos
}
\begin{cfuncdesc}
{
PyObject*
}{
PyTuple
_
GET
_
ITEM
}{
PyTupleObject *p, int pos
}
...
@@ -1873,7 +1897,10 @@ Returns the length of the list object in \var{list}.
...
@@ -1873,7 +1897,10 @@ Returns the length of the list object in \var{list}.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GetItem
}{
PyObject *list, int index
}
\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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
SetItem
}{
PyObject *list, int index,
\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}.
...
@@ -1882,36 +1909,40 @@ Sets the item at index \var{index} in list to \var{item}.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
Insert
}{
PyObject *list, int index,
\begin{cfuncdesc}
{
int
}{
PyList
_
Insert
}{
PyObject *list, int index,
PyObject *index
}
PyObject *item
}
Inserts the item
\var
{
item
}
into list
\var
{
list
}
in front of index
\var
{
index
}
Inserts the item
\var
{
item
}
into list
\var
{
list
}
in front of index
and returns true if successful.
\var
{
index
}
. Returns 0 if successful; returns -1 and sets an
For example:
exception if unsuccessful. Analogous to
\code
{
list.insert(index, item)
}
.
\begin{verbatim}
PyList
_
Insert(list, 0, object);
\end{verbatim}
\end{cfuncdesc}
\end{cfuncdesc}
would insert
\var
{
object
}
at the front of the list.
\begin{cfuncdesc}
{
int
}{
PyList
_
Append
}{
PyObject *list, PyObject *item
}
\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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GetSlice
}{
PyObject *list,
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GetSlice
}{
PyObject *list,
int low, int high
}
int low, int high
}
Returns a list of the objects in
\var
{
list
}
containing the objects
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
SetSlice
}{
PyObject *list,
\begin{cfuncdesc}
{
int
}{
PyList
_
SetSlice
}{
PyObject *list,
int low, int high,
int low, int high,
PyObject *itemlist
}
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
Sort
}{
PyObject *list
}
\begin{cfuncdesc}
{
int
}{
PyList
_
Sort
}{
PyObject *list
}
Sorts the items of
\var
{
list
}
in place. Returns 0 on success, -1 on failure.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
Reverse
}{
PyObject *list
}
\begin{cfuncdesc}
{
int
}{
PyList
_
Reverse
}{
PyObject *list
}
Reverses the items of
\var
{
list
}
in place. Returns 0 on success, -1 on failure.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
AsTuple
}{
PyObject *list
}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
AsTuple
}{
PyObject *list
}
...
@@ -1919,9 +1950,11 @@ Returns a new tuple object containing the contents of \var{list}.
...
@@ -1919,9 +1950,11 @@ Returns a new tuple object containing the contents of \var{list}.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GET
_
ITEM
}{
PyObject *list, int i
}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GET
_
ITEM
}{
PyObject *list, int i
}
Macro form of
\code
{
PyList
_
GetItem
}
without error checking.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
GET
_
SIZE
}{
PyObject *list
}
\begin{cfuncdesc}
{
int
}{
PyList
_
GET
_
SIZE
}{
PyObject *list
}
Macro form of
\code
{
PyList
_
GetSize
}
without error checking.
\end{cfuncdesc}
\end{cfuncdesc}
...
@@ -1979,29 +2012,31 @@ specified by the \code{char *}\var{key}.
...
@@ -1979,29 +2012,31 @@ specified by the \code{char *}\var{key}.
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
GetItem
}{
PyDictObject *p, PyObject *key
}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
GetItem
}{
PyDictObject *p, PyObject *key
}
Returns the object from dictionary
\var
{
p
}
which has a 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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
GetItemString
}{
PyDictObject *p, char *key
}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
GetItemString
}{
PyDictObject *p, char *key
}
Does the same, but
\var
{
key
}
is specified as a
This is the same as
\code
{
PyDict
_
GetItem()
}
, but
\var
{
key
}
is
\code
{
char *
}
, rather than a
\code
{
PyObject *
}
.
specified as a
\code
{
char *
}
, rather than a
\code
{
PyObject *
}
.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Items
}{
PyDictObject *p
}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Items
}{
PyDictObject *p
}
Returns a
\code
{
PyListObject
}
containing all the items
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
}
).
the
\emph
{
Python Library Reference
}
).
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Keys
}{
PyDictObject *p
}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Keys
}{
PyDictObject *p
}
Returns a
\code
{
PyListObject
}
containing all the keys
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
}
).
\emph
{
Python Library Reference
}
).
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Values
}{
PyDictObject *p
}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Values
}{
PyDictObject *p
}
Returns a
\code
{
PyListObject
}
containing all the values
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
}
).
\method
{
values()
}
(see the
\emph
{
Python Library Reference
}
).
\end{cfuncdesc}
\end{cfuncdesc}
...
@@ -2093,16 +2128,16 @@ Returns a new \code{PyLong} object from the integer part of \var{v}.
...
@@ -2093,16 +2128,16 @@ Returns a new \code{PyLong} object from the integer part of \var{v}.
\begin{cfuncdesc}
{
long
}{
PyLong
_
AsLong
}{
PyObject *pylong
}
\begin{cfuncdesc}
{
long
}{
PyLong
_
AsLong
}{
PyObject *pylong
}
Returns a
\C
{}
\code
{
long
}
representation of the contents of
\var
{
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
unsigned long
}{
PyLong
_
AsUnsignedLong
}{
PyObject *pylong
}
\begin{cfuncdesc}
{
unsigned long
}{
PyLong
_
AsUnsignedLong
}{
PyObject *pylong
}
Returns a
\C
{}
\code
{
unsigned long
}
representation of the contents of
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
double
}{
PyLong
_
AsDouble
}{
PyObject *pylong
}
\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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyLong
_
FromString
}{
char *str, char **pend,
\begin{cfuncdesc}
{
PyObject*
}{
PyLong
_
FromString
}{
char *str, char **pend,
...
@@ -2278,8 +2313,37 @@ Writes string \var{s} to file object \var{p}.
...
@@ -2278,8 +2313,37 @@ Writes string \var{s} to file object \var{p}.
\subsection
{
CObjects
}
\subsection
{
CObjects
}
\label
{
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
}
\chapter
{
Initialization, Finalization, and Threads
}
\label
{
initialization
}
\label
{
initialization
}
...
...
Doc/api/api.tex
Dosyayı görüntüle @
4447513e
...
@@ -980,7 +980,8 @@ check the modules dictionary if there's one there, and if not, create
...
@@ -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
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
action is most common, this does not return a new reference, and you
do not own the returned reference. Return
\NULL
{}
with an
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyImport
_
ExecCodeModule
}{
char *name, PyObject *co
}
\begin{cfuncdesc}
{
PyObject*
}{
PyImport
_
ExecCodeModule
}{
char *name, PyObject *co
}
...
@@ -1697,7 +1698,8 @@ This section describes Python type objects and the singleton object
...
@@ -1697,7 +1698,8 @@ This section describes Python type objects and the singleton object
\label
{
noneObject
}
\label
{
noneObject
}
\begin{cvardesc}
{
PyObject *
}{
Py
_
None
}
\begin{cvardesc}
{
PyObject *
}{
Py
_
None
}
XXX macro
The Python
\code
{
None
}
object, denoting lack of value. This object has
no methods.
\end{cvardesc}
\end{cvardesc}
...
@@ -1753,32 +1755,53 @@ of \var{newpart} appended to \var{string}.
...
@@ -1753,32 +1755,53 @@ of \var{newpart} appended to \var{string}.
\begin{cfuncdesc}
{
void
}{
PyString
_
ConcatAndDel
}{
PyObject **string,
\begin{cfuncdesc}
{
void
}{
PyString
_
ConcatAndDel
}{
PyObject **string,
PyObject *newpart
}
PyObject *newpart
}
Creates a new string object in
\var
{
*string
}
containing the contents
Creates a new string object in
\var
{
*string
}
containing the contents
of
\var
{
newpart
}
appended to
\var
{
string
}
.
--WHAT IS THE
of
\var
{
newpart
}
appended to
\var
{
string
}
.
This version decrements
DIFFERENCE BETWEEN THIS AND PLAIN CONCAT?--
the reference count of
\var
{
newpart
}
.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{_
PyString
_
Resize
}{
PyObject **string, int newsize
}
\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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyString
_
Format
}{
PyObject *format,
\begin{cfuncdesc}
{
PyObject*
}{
PyString
_
Format
}{
PyObject *format,
PyObject *args
}
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
void
}{
PyString
_
InternInPlace
}{
PyObject **string
}
\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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyString
_
InternFromString
}{
const char *v
}
\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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
char*
}{
PyString
_
AS
_
STRING
}{
PyObject *string
}
\begin{cfuncdesc}
{
char*
}{
PyString
_
AS
_
STRING
}{
PyObject *string
}
Macro form of
\code
{
PyString
_
AsString
}
but without error checking.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyString
_
GET
_
SIZE
}{
PyObject *string
}
\begin{cfuncdesc}
{
int
}{
PyString
_
GET
_
SIZE
}{
PyObject *string
}
Macro form of
\code
{
PyString
_
GetSize
}
but without error checking.
\end{cfuncdesc}
\end{cfuncdesc}
\subsection
{
Tuple Objects
}
\subsection
{
Tuple Objects
}
\label
{
tupleObjects
}
\label
{
tupleObjects
}
...
@@ -1806,7 +1829,8 @@ of that tuple.
...
@@ -1806,7 +1829,8 @@ of that tuple.
\begin{cfuncdesc}
{
PyObject*
}{
PyTuple
_
GetItem
}{
PyTupleObject *p, int pos
}
\begin{cfuncdesc}
{
PyObject*
}{
PyTuple
_
GetItem
}{
PyTupleObject *p, int pos
}
Returns the object at position
\var
{
pos
}
in the tuple pointed
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
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyTuple
_
GET
_
ITEM
}{
PyTupleObject *p, int pos
}
\begin{cfuncdesc}
{
PyObject*
}{
PyTuple
_
GET
_
ITEM
}{
PyTupleObject *p, int pos
}
...
@@ -1873,7 +1897,10 @@ Returns the length of the list object in \var{list}.
...
@@ -1873,7 +1897,10 @@ Returns the length of the list object in \var{list}.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GetItem
}{
PyObject *list, int index
}
\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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
SetItem
}{
PyObject *list, int index,
\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}.
...
@@ -1882,36 +1909,40 @@ Sets the item at index \var{index} in list to \var{item}.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
Insert
}{
PyObject *list, int index,
\begin{cfuncdesc}
{
int
}{
PyList
_
Insert
}{
PyObject *list, int index,
PyObject *index
}
PyObject *item
}
Inserts the item
\var
{
item
}
into list
\var
{
list
}
in front of index
\var
{
index
}
Inserts the item
\var
{
item
}
into list
\var
{
list
}
in front of index
and returns true if successful.
\var
{
index
}
. Returns 0 if successful; returns -1 and sets an
For example:
exception if unsuccessful. Analogous to
\code
{
list.insert(index, item)
}
.
\begin{verbatim}
PyList
_
Insert(list, 0, object);
\end{verbatim}
\end{cfuncdesc}
\end{cfuncdesc}
would insert
\var
{
object
}
at the front of the list.
\begin{cfuncdesc}
{
int
}{
PyList
_
Append
}{
PyObject *list, PyObject *item
}
\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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GetSlice
}{
PyObject *list,
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GetSlice
}{
PyObject *list,
int low, int high
}
int low, int high
}
Returns a list of the objects in
\var
{
list
}
containing the objects
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
SetSlice
}{
PyObject *list,
\begin{cfuncdesc}
{
int
}{
PyList
_
SetSlice
}{
PyObject *list,
int low, int high,
int low, int high,
PyObject *itemlist
}
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
Sort
}{
PyObject *list
}
\begin{cfuncdesc}
{
int
}{
PyList
_
Sort
}{
PyObject *list
}
Sorts the items of
\var
{
list
}
in place. Returns 0 on success, -1 on failure.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
Reverse
}{
PyObject *list
}
\begin{cfuncdesc}
{
int
}{
PyList
_
Reverse
}{
PyObject *list
}
Reverses the items of
\var
{
list
}
in place. Returns 0 on success, -1 on failure.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
AsTuple
}{
PyObject *list
}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
AsTuple
}{
PyObject *list
}
...
@@ -1919,9 +1950,11 @@ Returns a new tuple object containing the contents of \var{list}.
...
@@ -1919,9 +1950,11 @@ Returns a new tuple object containing the contents of \var{list}.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GET
_
ITEM
}{
PyObject *list, int i
}
\begin{cfuncdesc}
{
PyObject*
}{
PyList
_
GET
_
ITEM
}{
PyObject *list, int i
}
Macro form of
\code
{
PyList
_
GetItem
}
without error checking.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyList
_
GET
_
SIZE
}{
PyObject *list
}
\begin{cfuncdesc}
{
int
}{
PyList
_
GET
_
SIZE
}{
PyObject *list
}
Macro form of
\code
{
PyList
_
GetSize
}
without error checking.
\end{cfuncdesc}
\end{cfuncdesc}
...
@@ -1979,29 +2012,31 @@ specified by the \code{char *}\var{key}.
...
@@ -1979,29 +2012,31 @@ specified by the \code{char *}\var{key}.
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
GetItem
}{
PyDictObject *p, PyObject *key
}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
GetItem
}{
PyDictObject *p, PyObject *key
}
Returns the object from dictionary
\var
{
p
}
which has a 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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
GetItemString
}{
PyDictObject *p, char *key
}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
GetItemString
}{
PyDictObject *p, char *key
}
Does the same, but
\var
{
key
}
is specified as a
This is the same as
\code
{
PyDict
_
GetItem()
}
, but
\var
{
key
}
is
\code
{
char *
}
, rather than a
\code
{
PyObject *
}
.
specified as a
\code
{
char *
}
, rather than a
\code
{
PyObject *
}
.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Items
}{
PyDictObject *p
}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Items
}{
PyDictObject *p
}
Returns a
\code
{
PyListObject
}
containing all the items
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
}
).
the
\emph
{
Python Library Reference
}
).
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Keys
}{
PyDictObject *p
}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Keys
}{
PyDictObject *p
}
Returns a
\code
{
PyListObject
}
containing all the keys
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
}
).
\emph
{
Python Library Reference
}
).
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Values
}{
PyDictObject *p
}
\begin{cfuncdesc}
{
PyObject*
}{
PyDict
_
Values
}{
PyDictObject *p
}
Returns a
\code
{
PyListObject
}
containing all the values
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
}
).
\method
{
values()
}
(see the
\emph
{
Python Library Reference
}
).
\end{cfuncdesc}
\end{cfuncdesc}
...
@@ -2093,16 +2128,16 @@ Returns a new \code{PyLong} object from the integer part of \var{v}.
...
@@ -2093,16 +2128,16 @@ Returns a new \code{PyLong} object from the integer part of \var{v}.
\begin{cfuncdesc}
{
long
}{
PyLong
_
AsLong
}{
PyObject *pylong
}
\begin{cfuncdesc}
{
long
}{
PyLong
_
AsLong
}{
PyObject *pylong
}
Returns a
\C
{}
\code
{
long
}
representation of the contents of
\var
{
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
unsigned long
}{
PyLong
_
AsUnsignedLong
}{
PyObject *pylong
}
\begin{cfuncdesc}
{
unsigned long
}{
PyLong
_
AsUnsignedLong
}{
PyObject *pylong
}
Returns a
\C
{}
\code
{
unsigned long
}
representation of the contents of
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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
double
}{
PyLong
_
AsDouble
}{
PyObject *pylong
}
\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}
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyLong
_
FromString
}{
char *str, char **pend,
\begin{cfuncdesc}
{
PyObject*
}{
PyLong
_
FromString
}{
char *str, char **pend,
...
@@ -2278,8 +2313,37 @@ Writes string \var{s} to file object \var{p}.
...
@@ -2278,8 +2313,37 @@ Writes string \var{s} to file object \var{p}.
\subsection
{
CObjects
}
\subsection
{
CObjects
}
\label
{
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
}
\chapter
{
Initialization, Finalization, and Threads
}
\label
{
initialization
}
\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