Skip to content

Commit 0ee2307

Browse files
committed
Add struct typeobject examples for Python 3.6, 3.7, 3.8 3.9, 3.10, 3.11, 3.12, 3.13.
1 parent 050249d commit 0ee2307

11 files changed

+886
-0
lines changed

Diff for: MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
graft type_objects

Diff for: type_objects/Python_3.10.1.h

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
//
2+
// Created by Paul Ross on 28/06/2024.
3+
//
4+
5+
#ifndef PYTHONEXTENSIONSBASIC_PYTHON_3_10_1_H
6+
#define PYTHONEXTENSIONSBASIC_PYTHON_3_10_1_H
7+
8+
struct _typeobject {
9+
PyObject_VAR_HEAD
10+
const char *tp_name; /* For printing, in format "<module>.<name>" */
11+
Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
12+
13+
/* Methods to implement standard operations */
14+
15+
destructor tp_dealloc;
16+
Py_ssize_t tp_vectorcall_offset;
17+
getattrfunc tp_getattr;
18+
setattrfunc tp_setattr;
19+
PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)
20+
or tp_reserved (Python 3) */
21+
reprfunc tp_repr;
22+
23+
/* Method suites for standard classes */
24+
25+
PyNumberMethods *tp_as_number;
26+
PySequenceMethods *tp_as_sequence;
27+
PyMappingMethods *tp_as_mapping;
28+
29+
/* More standard operations (here for binary compatibility) */
30+
31+
hashfunc tp_hash;
32+
ternaryfunc tp_call;
33+
reprfunc tp_str;
34+
getattrofunc tp_getattro;
35+
setattrofunc tp_setattro;
36+
37+
/* Functions to access object as input/output buffer */
38+
PyBufferProcs *tp_as_buffer;
39+
40+
/* Flags to define presence of optional/expanded features */
41+
unsigned long tp_flags;
42+
43+
const char *tp_doc; /* Documentation string */
44+
45+
/* Assigned meaning in release 2.0 */
46+
/* call function for all accessible objects */
47+
traverseproc tp_traverse;
48+
49+
/* delete references to contained objects */
50+
inquiry tp_clear;
51+
52+
/* Assigned meaning in release 2.1 */
53+
/* rich comparisons */
54+
richcmpfunc tp_richcompare;
55+
56+
/* weak reference enabler */
57+
Py_ssize_t tp_weaklistoffset;
58+
59+
/* Iterators */
60+
getiterfunc tp_iter;
61+
iternextfunc tp_iternext;
62+
63+
/* Attribute descriptor and subclassing stuff */
64+
struct PyMethodDef *tp_methods;
65+
struct PyMemberDef *tp_members;
66+
struct PyGetSetDef *tp_getset;
67+
// Strong reference on a heap type, borrowed reference on a static type
68+
struct _typeobject *tp_base;
69+
PyObject *tp_dict;
70+
descrgetfunc tp_descr_get;
71+
descrsetfunc tp_descr_set;
72+
Py_ssize_t tp_dictoffset;
73+
initproc tp_init;
74+
allocfunc tp_alloc;
75+
newfunc tp_new;
76+
freefunc tp_free; /* Low-level free-memory routine */
77+
inquiry tp_is_gc; /* For PyObject_IS_GC */
78+
PyObject *tp_bases;
79+
PyObject *tp_mro; /* method resolution order */
80+
PyObject *tp_cache;
81+
PyObject *tp_subclasses;
82+
PyObject *tp_weaklist;
83+
destructor tp_del;
84+
85+
/* Type attribute cache version tag. Added in version 2.6 */
86+
unsigned int tp_version_tag;
87+
88+
destructor tp_finalize;
89+
vectorcallfunc tp_vectorcall;
90+
};
91+
92+
#endif //PYTHONEXTENSIONSBASIC_PYTHON_3_10_1_H

Diff for: type_objects/Python_3.11.1.h

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
//
2+
// Created by Paul Ross on 28/06/2024.
3+
//
4+
5+
#ifndef PYTHONEXTENSIONSBASIC_PYTHON_3_11_1_H
6+
#define PYTHONEXTENSIONSBASIC_PYTHON_3_11_1_H
7+
8+
struct _typeobject {
9+
PyObject_VAR_HEAD
10+
const char *tp_name; /* For printing, in format "<module>.<name>" */
11+
Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
12+
13+
/* Methods to implement standard operations */
14+
15+
destructor tp_dealloc;
16+
Py_ssize_t tp_vectorcall_offset;
17+
getattrfunc tp_getattr;
18+
setattrfunc tp_setattr;
19+
PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)
20+
or tp_reserved (Python 3) */
21+
reprfunc tp_repr;
22+
23+
/* Method suites for standard classes */
24+
25+
PyNumberMethods *tp_as_number;
26+
PySequenceMethods *tp_as_sequence;
27+
PyMappingMethods *tp_as_mapping;
28+
29+
/* More standard operations (here for binary compatibility) */
30+
31+
hashfunc tp_hash;
32+
ternaryfunc tp_call;
33+
reprfunc tp_str;
34+
getattrofunc tp_getattro;
35+
setattrofunc tp_setattro;
36+
37+
/* Functions to access object as input/output buffer */
38+
PyBufferProcs *tp_as_buffer;
39+
40+
/* Flags to define presence of optional/expanded features */
41+
unsigned long tp_flags;
42+
43+
const char *tp_doc; /* Documentation string */
44+
45+
/* Assigned meaning in release 2.0 */
46+
/* call function for all accessible objects */
47+
traverseproc tp_traverse;
48+
49+
/* delete references to contained objects */
50+
inquiry tp_clear;
51+
52+
/* Assigned meaning in release 2.1 */
53+
/* rich comparisons */
54+
richcmpfunc tp_richcompare;
55+
56+
/* weak reference enabler */
57+
Py_ssize_t tp_weaklistoffset;
58+
59+
/* Iterators */
60+
getiterfunc tp_iter;
61+
iternextfunc tp_iternext;
62+
63+
/* Attribute descriptor and subclassing stuff */
64+
PyMethodDef *tp_methods;
65+
PyMemberDef *tp_members;
66+
PyGetSetDef *tp_getset;
67+
// Strong reference on a heap type, borrowed reference on a static type
68+
PyTypeObject *tp_base;
69+
PyObject *tp_dict;
70+
descrgetfunc tp_descr_get;
71+
descrsetfunc tp_descr_set;
72+
Py_ssize_t tp_dictoffset;
73+
initproc tp_init;
74+
allocfunc tp_alloc;
75+
newfunc tp_new;
76+
freefunc tp_free; /* Low-level free-memory routine */
77+
inquiry tp_is_gc; /* For PyObject_IS_GC */
78+
PyObject *tp_bases;
79+
PyObject *tp_mro; /* method resolution order */
80+
PyObject *tp_cache;
81+
PyObject *tp_subclasses;
82+
PyObject *tp_weaklist;
83+
destructor tp_del;
84+
85+
/* Type attribute cache version tag. Added in version 2.6 */
86+
unsigned int tp_version_tag;
87+
88+
destructor tp_finalize;
89+
vectorcallfunc tp_vectorcall;
90+
};
91+
92+
#endif //PYTHONEXTENSIONSBASIC_PYTHON_3_11_1_H

Diff for: type_objects/Python_3.12.1.h

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
//
2+
// Created by Paul Ross on 28/06/2024.
3+
//
4+
5+
#ifndef PYTHONEXTENSIONSBASIC_PYTHON_3_12_1_H
6+
#define PYTHONEXTENSIONSBASIC_PYTHON_3_12_1_H
7+
8+
struct _typeobject {
9+
PyObject_VAR_HEAD
10+
const char *tp_name; /* For printing, in format "<module>.<name>" */
11+
Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
12+
13+
/* Methods to implement standard operations */
14+
15+
destructor tp_dealloc;
16+
Py_ssize_t tp_vectorcall_offset;
17+
getattrfunc tp_getattr;
18+
setattrfunc tp_setattr;
19+
PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)
20+
or tp_reserved (Python 3) */
21+
reprfunc tp_repr;
22+
23+
/* Method suites for standard classes */
24+
25+
PyNumberMethods *tp_as_number;
26+
PySequenceMethods *tp_as_sequence;
27+
PyMappingMethods *tp_as_mapping;
28+
29+
/* More standard operations (here for binary compatibility) */
30+
31+
hashfunc tp_hash;
32+
ternaryfunc tp_call;
33+
reprfunc tp_str;
34+
getattrofunc tp_getattro;
35+
setattrofunc tp_setattro;
36+
37+
/* Functions to access object as input/output buffer */
38+
PyBufferProcs *tp_as_buffer;
39+
40+
/* Flags to define presence of optional/expanded features */
41+
unsigned long tp_flags;
42+
43+
const char *tp_doc; /* Documentation string */
44+
45+
/* Assigned meaning in release 2.0 */
46+
/* call function for all accessible objects */
47+
traverseproc tp_traverse;
48+
49+
/* delete references to contained objects */
50+
inquiry tp_clear;
51+
52+
/* Assigned meaning in release 2.1 */
53+
/* rich comparisons */
54+
richcmpfunc tp_richcompare;
55+
56+
/* weak reference enabler */
57+
Py_ssize_t tp_weaklistoffset;
58+
59+
/* Iterators */
60+
getiterfunc tp_iter;
61+
iternextfunc tp_iternext;
62+
63+
/* Attribute descriptor and subclassing stuff */
64+
PyMethodDef *tp_methods;
65+
PyMemberDef *tp_members;
66+
PyGetSetDef *tp_getset;
67+
// Strong reference on a heap type, borrowed reference on a static type
68+
PyTypeObject *tp_base;
69+
PyObject *tp_dict;
70+
descrgetfunc tp_descr_get;
71+
descrsetfunc tp_descr_set;
72+
Py_ssize_t tp_dictoffset;
73+
initproc tp_init;
74+
allocfunc tp_alloc;
75+
newfunc tp_new;
76+
freefunc tp_free; /* Low-level free-memory routine */
77+
inquiry tp_is_gc; /* For PyObject_IS_GC */
78+
PyObject *tp_bases;
79+
PyObject *tp_mro; /* method resolution order */
80+
PyObject *tp_cache; /* no longer used */
81+
void *tp_subclasses; /* for static builtin types this is an index */
82+
PyObject *tp_weaklist; /* not used for static builtin types */
83+
destructor tp_del;
84+
85+
/* Type attribute cache version tag. Added in version 2.6 */
86+
unsigned int tp_version_tag;
87+
88+
destructor tp_finalize;
89+
vectorcallfunc tp_vectorcall;
90+
91+
/* bitset of which type-watchers care about this type */
92+
unsigned char tp_watched;
93+
};
94+
95+
96+
#endif //PYTHONEXTENSIONSBASIC_PYTHON_3_12_1_H

Diff for: type_objects/Python_3.13.0b3.h

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
//
2+
// Created by Paul Ross on 28/06/2024.
3+
//
4+
5+
#define PYTHONEXTENSIONSBASIC_PYTHON_3_13_0b3_H
6+
#ifndef PYTHONEXTENSIONSBASIC_PYTHON_3_13_0b3_H
7+
8+
struct _typeobject {
9+
PyObject_VAR_HEAD
10+
const char *tp_name; /* For printing, in format "<module>.<name>" */
11+
Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
12+
13+
/* Methods to implement standard operations */
14+
15+
destructor tp_dealloc;
16+
Py_ssize_t tp_vectorcall_offset;
17+
getattrfunc tp_getattr;
18+
setattrfunc tp_setattr;
19+
PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)
20+
or tp_reserved (Python 3) */
21+
reprfunc tp_repr;
22+
23+
/* Method suites for standard classes */
24+
25+
PyNumberMethods *tp_as_number;
26+
PySequenceMethods *tp_as_sequence;
27+
PyMappingMethods *tp_as_mapping;
28+
29+
/* More standard operations (here for binary compatibility) */
30+
31+
hashfunc tp_hash;
32+
ternaryfunc tp_call;
33+
reprfunc tp_str;
34+
getattrofunc tp_getattro;
35+
setattrofunc tp_setattro;
36+
37+
/* Functions to access object as input/output buffer */
38+
PyBufferProcs *tp_as_buffer;
39+
40+
/* Flags to define presence of optional/expanded features */
41+
unsigned long tp_flags;
42+
43+
const char *tp_doc; /* Documentation string */
44+
45+
/* Assigned meaning in release 2.0 */
46+
/* call function for all accessible objects */
47+
traverseproc tp_traverse;
48+
49+
/* delete references to contained objects */
50+
inquiry tp_clear;
51+
52+
/* Assigned meaning in release 2.1 */
53+
/* rich comparisons */
54+
richcmpfunc tp_richcompare;
55+
56+
/* weak reference enabler */
57+
Py_ssize_t tp_weaklistoffset;
58+
59+
/* Iterators */
60+
getiterfunc tp_iter;
61+
iternextfunc tp_iternext;
62+
63+
/* Attribute descriptor and subclassing stuff */
64+
PyMethodDef *tp_methods;
65+
PyMemberDef *tp_members;
66+
PyGetSetDef *tp_getset;
67+
// Strong reference on a heap type, borrowed reference on a static type
68+
PyTypeObject *tp_base;
69+
PyObject *tp_dict;
70+
descrgetfunc tp_descr_get;
71+
descrsetfunc tp_descr_set;
72+
Py_ssize_t tp_dictoffset;
73+
initproc tp_init;
74+
allocfunc tp_alloc;
75+
newfunc tp_new;
76+
freefunc tp_free; /* Low-level free-memory routine */
77+
inquiry tp_is_gc; /* For PyObject_IS_GC */
78+
PyObject *tp_bases;
79+
PyObject *tp_mro; /* method resolution order */
80+
PyObject *tp_cache; /* no longer used */
81+
void *tp_subclasses; /* for static builtin types this is an index */
82+
PyObject *tp_weaklist; /* not used for static builtin types */
83+
destructor tp_del;
84+
85+
/* Type attribute cache version tag. Added in version 2.6 */
86+
unsigned int tp_version_tag;
87+
88+
destructor tp_finalize;
89+
vectorcallfunc tp_vectorcall;
90+
91+
/* bitset of which type-watchers care about this type */
92+
unsigned char tp_watched;
93+
uint16_t tp_versions_used;
94+
};
95+
96+
97+
#endif // PYTHONEXTENSIONSBASIC_PYTHON_3_13_0b3_H

0 commit comments

Comments
 (0)