@@ -27,126 +27,186 @@ Latest version of the header file:
27
27
Python 3.11
28
28
-----------
29
29
30
- ::
30
+ .. c : function :: void PyThreadState_EnterTracing (PyThreadState * tstate)
31
31
32
- // Not available on PyPy
33
- void PyThreadState_EnterTracing(PyThreadState *tstate);
34
- // Not available on PyPy
35
- void PyThreadState_LeaveTracing(PyThreadState *tstate);
32
+ See `PyThreadState_EnterTracing() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_EnterTracing >`__.
33
+
34
+ Not available on PyPy.
35
+
36
+ .. c :function :: void PyThreadState_LeaveTracing (PyThreadState *tstate)
37
+
38
+ See `PyThreadState_LeaveTracing() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_LeaveTracing >`__.
39
+
40
+ Not available on PyPy
36
41
37
42
Python 3.10
38
43
-----------
39
44
40
- ::
45
+ .. c :function :: PyObject* Py_NewRef (PyObject *obj)
46
+
47
+ See `Py_NewRef() documentation <https://docs.python.org/dev/c-api/refcounting.html#c.Py_NewRef >`__.
48
+
49
+ .. c :function :: PyObject* Py_XNewRef (PyObject *obj)
50
+
51
+ See `Py_XNewRef() documentation <https://docs.python.org/dev/c-api/refcounting.html#c.Py_XNewRef >`__.
52
+
53
+ .. c :function :: int Py_Is (PyObject *x, PyObject *y)
54
+
55
+ See `Py_Is() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_Is >`__.
56
+
57
+ .. c :function :: int Py_IsNone (PyObject *x)
58
+
59
+ See `Py_IsNone() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_IsNone >`__.
60
+
61
+ .. c :function :: int Py_IsTrue (PyObject *x)
62
+
63
+ See `Py_IsTrue() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_IsTrue >`__.
41
64
42
- PyObject* Py_NewRef(PyObject *obj);
43
- PyObject* Py_XNewRef(PyObject *obj);
44
- int Py_Is(PyObject *x, PyObject *y);
45
- int Py_IsNone(PyObject *x);
46
- int Py_IsTrue(PyObject *x);
47
- int Py_IsFalse(PyObject *x);
65
+ .. c :function :: int Py_IsFalse (PyObject *x)
48
66
49
- int PyModule_AddObjectRef(PyObject *module, const char *name, PyObject *value);
67
+ See `Py_IsFalse() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_IsFalse >`__.
68
+
69
+ .. c :function :: int PyModule_AddObjectRef (PyObject *module, const char *name, PyObject *value)
70
+
71
+ See `PyModule_AddObjectRef() documentation <https://docs.python.org/dev/c-api/module.html#c.PyModule_AddObjectRef >`__.
50
72
51
73
Python 3.9
52
74
----------
53
75
54
76
PyObject
55
77
^^^^^^^^
56
78
57
- ::
79
+ .. c :function :: void Py_SET_REFCNT (PyObject *ob, Py_ssize_t refcnt)
80
+
81
+ See `Py_SET_REFCNT() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_SET_REFCNT >`__.
82
+
83
+ .. c :function :: void Py_SET_TYPE (PyObject *ob, PyTypeObject *type)
84
+
85
+ See `Py_SET_TYPE() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_SET_TYPE >`__.
86
+
87
+ .. c :function :: void Py_SET_SIZE (PyVarObject *ob, Py_ssize_t size)
88
+
89
+ See `Py_SET_SIZE() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_SET_SIZE >`__.
58
90
59
- void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt);
60
- void Py_SET_TYPE(PyObject *ob, PyTypeObject *type);
61
- void Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size);
62
- int Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type);
91
+ .. c :function :: int Py_IS_TYPE (const PyObject *ob, const PyTypeObject *type)
92
+
93
+ See `Py_IS_TYPE() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_IS_TYPE >`__.
94
+
95
+ .. c :function :: PyObject* PyObject_CallNoArgs (PyObject *func)
96
+
97
+ See `PyObject_CallNoArgs() documentation <https://docs.python.org/dev/c-api/call.html#c.PyObject_CallNoArgs >`__.
98
+
99
+ .. c :function :: PyObject* PyObject_CallOneArg (PyObject *func, PyObject *arg)
100
+
101
+ See `PyObject_CallOneArg() documentation <https://docs.python.org/dev/c-api/call.html#c.PyObject_CallOneArg >`__.
63
102
64
- PyObject* PyObject_CallNoArgs(PyObject *func);
65
- PyObject* PyObject_CallOneArg(PyObject *func, PyObject *arg);
66
103
67
104
PyFrameObject
68
105
^^^^^^^^^^^^^
69
106
70
- ::
107
+ .. c :function :: PyCodeObject* PyFrame_GetCode (PyFrameObject *frame)
108
+
109
+ See `PyFrame_GetCode() documentation <https://docs.python.org/dev/c-api/reflection.html#c.PyFrame_GetCode >`__.
110
+
111
+ .. c :function :: PyFrameObject* PyFrame_GetBack (PyFrameObject *frame)
112
+
113
+ See `PyFrame_GetBack() documentation <https://docs.python.org/dev/c-api/reflection.html#c.PyFrame_GetBack >`__.
114
+
115
+ Not available on PyPy
71
116
72
- PyCodeObject* PyFrame_GetCode(PyFrameObject *frame);
73
- // Not available on PyPy
74
- PyFrameObject* PyFrame_GetBack(PyFrameObject *frame);
75
117
76
118
PyThreadState
77
119
^^^^^^^^^^^^^
78
120
79
- ::
121
+ .. c :function :: PyFrameObject* PyThreadState_GetFrame (PyThreadState *tstate)
122
+
123
+ See `PyThreadState_GetFrame() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_GetFrame >`__.
124
+
125
+ Not available on PyPy
126
+
127
+ .. c :function :: PyInterpreterState* PyThreadState_GetInterpreter (PyThreadState *tstate)
128
+
129
+ See `PyThreadState_GetInterpreter() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_GetInterpreter >`__.
80
130
81
- // Not available on PyPy
82
- PyFrameObject* PyThreadState_GetFrame(PyThreadState *tstate);
83
- PyInterpreterState* PyThreadState_GetInterpreter(PyThreadState *tstate);
84
- // Availability: Python 3.7. Not available on PyPy.
85
- uint64_t PyThreadState_GetID(PyThreadState *tstate);
131
+ .. c : function :: uint64_t PyThreadState_GetID (PyThreadState * tstate)
132
+
133
+ See ` PyThreadState_GetID() documentation < https://docs.python.org/dev/c-api/init.html#c.PyThreadState_GetID >`__.
134
+
135
+ Availability: Python 3.7. Not available on PyPy.
86
136
87
137
PyInterpreterState
88
138
^^^^^^^^^^^^^^^^^^
89
139
90
- ::
140
+ .. c :function :: PyInterpreterState* PyInterpreterState_Get (void)
141
+
142
+ See `PyInterpreterState_Get() documentation <https:// docs.python.org/dev/c-api/init.html#c.PyInterpreterState_Get>`__.
91
143
92
- PyInterpreterState* PyInterpreterState_Get(void);
93
144
94
145
GC protocol
95
146
^^^^^^^^^^^
96
147
97
- ::
148
+ .. c:function:: int PyObject_GC_IsTracked(PyObject* obj)
149
+
150
+ See `PyObject_GC_IsTracked() documentation <https:// docs.python.org/dev/c-api/gcsupport.html#c.PyObject_GC_IsTracked>`__.
151
+
152
+ Not available on PyPy.
153
+
154
+ .. c:function:: int PyObject_GC_IsFinalized(PyObject *obj)
98
155
99
- // Not available on PyPy.
100
- int PyObject_GC_IsTracked(PyObject* obj);
101
- // Availability: Python 3.4. Not available on PyPy.
102
- int PyObject_GC_IsFinalized(PyObject *obj);
156
+ See `PyObject_GC_IsFinalized() documentation <https://docs.python.org/dev/c-api/gcsupport.html#c.PyObject_GC_IsFinalized >`__.
157
+
158
+ Availability: Python 3.4. Not available on PyPy.
103
159
104
160
Module helper
105
161
^^^^^^^^^^^^^
106
162
107
- ::
163
+ .. c : function :: int PyModule_AddType (PyObject * module, PyTypeObject *type)
108
164
109
- int PyModule_AddType(PyObject *module, PyTypeObject *type);
165
+ See ` PyModule_AddType() documentation < https://docs.python.org/dev/c-api/module.html#c.PyModule_AddType >`__.
110
166
111
167
Python 3.5.2
112
168
------------
113
169
114
- ::
170
+ .. c : macro :: Py_SETREF(op, op2)
115
171
116
- Py_SETREF(op, op2)
117
- Py_XSETREF(op, op2)
172
+ .. c :macro :: Py_XSETREF(op, op2)
118
173
119
174
Python 3.4
120
175
----------
121
176
122
- ::
177
+ .. c : macro :: Py_UNUSED(name)
123
178
124
- Py_UNUSED(name)
179
+ See ` Py_UNUSED() documentation < https://docs.python.org/dev/c-api/intro.html#c.Py_UNUSED >`__.
125
180
126
181
Borrow variant
127
182
--------------
128
183
129
184
To ease migration of C extensions to the new C API, a variant is provided
130
- to return borrowed references rather than strong references::
185
+ to return borrowed references rather than strong references.
186
+
187
+ These functions are only available in ``pythoncapi_compat.h `` and are not
188
+ part of the Python C API.
189
+
190
+ .. c :function :: PyObject* _Py_StealRef (PyObject *ob)
191
+
192
+ Similar to ``Py_DECREF(ob); return ob; ``.
131
193
132
- // Similar to "Py_DECREF(ob); return ob;"
133
- PyObject* _Py_StealRef(PyObject *ob);
194
+ .. c :function :: PyObject* _Py_XStealRef (PyObject *ob)
134
195
135
- // Similar to "Py_XDECREF(ob); return ob;"
136
- PyObject* _Py_XStealRef(PyObject *ob);
196
+ Similar to ``Py_XDECREF(ob); return ob; ``.
137
197
138
- // PyThreadState_GetFrame(). Not available on PyPy.
139
- PyFrameObject* _PyThreadState_GetFrameBorrow(PyThreadState *tstate)
198
+ .. c :function :: PyFrameObject* _PyThreadState_GetFrameBorrow (PyThreadState *tstate)
140
199
141
- // PyFrame_GetCode()
142
- PyCodeObject* _PyFrame_GetCodeBorrow(PyFrameObject *frame)
200
+ :c:func: `PyThreadState_GetFrame ` variant. Not available on PyPy.
143
201
144
- // PyFrame_GetBack(). Not available on PyPy.
145
- PyFrameObject* _PyFrame_GetBackBorrow(PyFrameObject *frame)
202
+ .. c :function :: PyCodeObject* _PyFrame_GetCodeBorrow (PyFrameObject *frame)
203
+
204
+ :c:func: `PyFrame_GetCode ` variant.
205
+
206
+ .. c :function :: PyFrameObject* _PyFrame_GetBackBorrow (PyFrameObject *frame)
207
+
208
+ :c:func: `PyFrame_GetBack ` variant Not available on PyPy.
146
209
147
210
For example, ``tstate->frame `` can be replaced with
148
211
``_PyThreadState_GetFrameBorrow(tstate) `` to avoid accessing directly
149
212
``PyThreadState.frame `` member.
150
-
151
- These functions are only available in ``pythoncapi_compat.h `` and are not
152
- part of the Python C API.
0 commit comments