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
4d61775a
Kaydet (Commit)
4d61775a
authored
Nis 09, 2002
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Started filling in the information about some of the basic types and macros
used to define Python objects.
üst
46cd7948
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
2 deletions
+69
-2
newtypes.tex
Doc/api/newtypes.tex
+69
-2
No files found.
Doc/api/newtypes.tex
Dosyayı görüntüle @
4d61775a
...
...
@@ -122,9 +122,71 @@ DL_IMPORT
\section
{
Common Object Structures
\label
{
common-structs
}}
PyObject, PyVarObject
There are a large number of structures which are used in the
definition of object types for Python. This section describes these
structures and how they are used.
All Python objects ultimately share a small number of fields at the
beginning of the object's representation in memory. These are
represented by the
\ctype
{
PyObject
}
and
\ctype
{
PyVarObject
}
types,
which are defined, in turn, by the expansions of some macros also
used, whether directly or indirectly, in the definition of all other
Python objects.
\begin{ctypedesc}
{
PyObject
}
All object types are extensions of this type. This is a type which
contains the information Python needs to treat a pointer to an
object as an object. In a normal ``release'' build, it contains
only the objects reference count and a pointer to the corresponding
type object. It corresponds to the fields defined by the
expansion of the
\code
{
PyObject
_
VAR
_
HEAD
}
macro.
\end{ctypedesc}
\begin{ctypedesc}
{
PyVarObject
}
This is an extension of
\ctype
{
PyObject
}
that adds the
\member
{
ob
_
size
}
field. This is only used for objects that have
some notion of
\emph
{
length
}
. This type does not often appear in
the Python/C API. It corresponds to the fields defined by the
expansion of the
\code
{
PyObject
_
VAR
_
HEAD
}
macro.
\end{ctypedesc}
PyObject
_
HEAD, PyObject
_
HEAD
_
INIT, PyObject
_
VAR
_
HEAD
These macros are used in the definition of
\ctype
{
PyObject
}
and
\ctype
{
PyVarObject
}
:
\begin{csimplemacrodesc}
{
PyObject
_
HEAD
}
This is a macro which expands to the declarations of the fields of
the
\ctype
{
PyObject
}
type; it is used when declaring new types which
represent objects without a varying length. The specific fields it
expands to depends on the definition of
\csimplemacro
{
Py
_
TRACE
_
REFS
}
. By default, that macro is not
defined, and
\csimplemacro
{
PyObject
_
HEAD
}
expands to:
\begin{verbatim}
int ob
_
refcnt;
PyTypeObject *ob
_
type;
\end{verbatim}
When
\csimplemacro
{
Py
_
TRACE
_
REFS
}
is defined, it expands to:
\begin{verbatim}
PyObject *
_
ob
_
next, *
_
ob
_
prev;
int ob
_
refcnt;
PyTypeObject *ob
_
type;
\end{verbatim}
\end{csimplemacrodesc}
\begin{csimplemacrodesc}
{
PyObject
_
VAR
_
HEAD
}
This is a macro which expands to the declarations of the fields of
the
\ctype
{
PyVarObject
}
type; it is used when declaring new types which
represent objects with a length that varies from instance to
instance. This macro always expands to:
\begin{verbatim}
PyObject
_
HEAD
int ob
_
size;
\end{verbatim}
Note that
\csimplemacro
{
PyObject
_
HEAD
}
is part of the expansion, and
that it's own expansion varies depending on the definition of
\csimplemacro
{
Py
_
TRACE
_
REFS
}
.
\end{csimplemacrodesc}
PyObject
_
HEAD
_
INIT
Typedefs:
unaryfunc, binaryfunc, ternaryfunc, inquiry, coercion, intargfunc,
...
...
@@ -134,6 +196,11 @@ setattrofunc, cmpfunc, reprfunc, hashfunc
\begin{ctypedesc}
{
PyCFunction
}
Type of the functions used to implement most Python callables in C.
Functions of this type take two
\ctype
{
PyObject*
}
parameters and
return one such value. If the return value is
\NULL
, an exception
shall have been set. If not
\NULL
, the return value is interpreted
as the return value of the function as exposed in Python. The
function must return a new reference.
\end{ctypedesc}
\begin{ctypedesc}
{
PyMethodDef
}
...
...
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