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
0f9a34da
Kaydet (Commit)
0f9a34da
authored
Mar 28, 2002
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added comments for more entries of the type structure in the example
type implementation.
üst
2ab0a109
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
newtypes.tex
Doc/ext/newtypes.tex
+19
-19
No files found.
Doc/ext/newtypes.tex
Dosyayı görüntüle @
0f9a34da
...
...
@@ -152,20 +152,20 @@ Moving on, we come to the crunch --- the type object.
\begin{verbatim}
static PyTypeObject noddy
_
NoddyType =
{
PyObject
_
HEAD
_
INIT(NULL)
0,
"Noddy",
sizeof(noddy
_
NoddyObject),
0,
noddy
_
noddy
_
dealloc,
/*tp
_
dealloc
*/
0,
/*tp
_
print
*/
0,
/*tp
_
getattr
*/
0,
/*tp
_
setattr
*/
0,
/*tp
_
compare
*/
0,
/*tp
_
repr
*/
0,
/*tp
_
as
_
number
*/
0,
/*tp
_
as
_
sequence
*/
0,
/*tp
_
as
_
mapping
*/
0,
/*
tp
_
hash */
0,
/* ob
_
size */
"Noddy",
/* tp
_
name */
sizeof(noddy
_
NoddyObject),
/* tp
_
basicsize */
0,
/* tp
_
itemsize */
noddy
_
noddy
_
dealloc,
/* tp
_
dealloc
*/
0,
/* tp
_
print
*/
0,
/* tp
_
getattr
*/
0,
/* tp
_
setattr
*/
0,
/* tp
_
compare
*/
0,
/* tp
_
repr
*/
0,
/* tp
_
as
_
number
*/
0,
/* tp
_
as
_
sequence
*/
0,
/* tp
_
as
_
mapping
*/
0,
/*
tp
_
hash */
}
;
\end{verbatim}
...
...
@@ -194,7 +194,7 @@ conforming C and some compilers complain. So instead we fill in the
oppourtunity --- in
\cfunction
{
initnoddy()
}
.
\begin{verbatim}
0,
0,
/* ob
_
size */
\end{verbatim}
The
\member
{
ob
_
size
}
field of the header is not used; it's presence in
...
...
@@ -203,7 +203,7 @@ binary compatibility with extension modules compiled for older
versions of Python. Always set this field to zero.
\begin{verbatim}
"Noddy",
"Noddy",
/* tp
_
name */
\end{verbatim}
The name of our type. This will appear in the default textual
...
...
@@ -217,14 +217,14 @@ TypeError: cannot add type "Noddy" to string
\end{verbatim}
\begin{verbatim}
sizeof(noddy
_
NoddyObject),
sizeof(noddy
_
NoddyObject),
/* tp
_
basicsize */
\end{verbatim}
This is so that Python knows how much memory to allocate when you call
\cfunction
{
PyObject
_
New
}
.
\begin{verbatim}
0,
0,
/* tp
_
itemsize */
\end{verbatim}
This has to do with variable length objects like lists and strings.
...
...
@@ -236,7 +236,7 @@ implement many of these, but as mentioned above you have to implement
the deallocation function.
\begin{verbatim}
noddy
_
noddy
_
dealloc,
/*tp
_
dealloc
*/
noddy
_
noddy
_
dealloc,
/* tp
_
dealloc
*/
\end{verbatim}
From here, all the type methods are
\NULL
, so I won't go over them yet
...
...
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