You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7aefdb2
Browse filesBrowse the repository at this point in the historyBrowse files
Add support for the limited C API (Py_LIMITED_API)
Examples of API not available in the limited C API:
* PyBytesWriter
* PyConfig_Get(), PyConfig_GetInt().
* PyDict_ContainsString().
* PyFrame_GetBack(), PyFrame_GetVar()
* PyLongWriter_Create() and PyLong_Export()
* PyObject_VisitManagedDict(), PyObject_ClearManagedDict()
* PyThreadState_GetUnchecked()
* PyTime_t API.
* PyUnicodeWriter
* PyUnstable_SetImmortal().
* Py_SETREF(), Py_XSETREF().
Implementation notes:
* PyUnicode_EqualToUTF8AndSize() has no ASCII fast path.
* PyLong_GetSign(), PyLong_IsPositive(), PyLong_IsNegative() and
PyLong_IsZero() are implemented with PyObject_RichCompareBool().
* PyBytes_Join() calls PyObject_CallMethod(sep, "join", iterable).
* Add PYTHONCAPI_COMPAT_EXPECT_TYPE() macro to raise TypeError.
There are 3 implementations depending on the API and Python
version.
test_pythoncapi_compat.py now reuses the setup module to list tests.
Closes#183
See `PyUnicodeWriter_WriteSubstring() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_WriteSubstring>`__.
185
228
229
+
Not available with the limited C API.
230
+
186
231
.. c:function:: int PyUnicodeWriter_Format(PyUnicodeWriter *writer, const char *format, ...)
187
232
188
233
See `PyUnicodeWriter_Format() documentation <https://docs.python.org/dev/c-api/unicode.html#c.PyUnicodeWriter_Format>`__.
189
234
235
+
Not available with the limited C API.
236
+
190
237
.. c:function:: int PyLong_AsInt32(PyObject *obj, int32_t *pvalue)
191
238
192
239
See `PyLong_AsInt32() documentation <https://docs.python.org/dev/c-api/long.html#c.PyLong_AsInt32>`__.
@@ -231,16 +278,22 @@ Python 3.14
231
278
232
279
See `PyConfig_Get() documentation <https://docs.python.org/dev/c-api/init_config.html#c.PyConfig_Get>`__.
233
280
281
+
Not available with the limited C API.
282
+
234
283
.. c:function:: int PyConfig_GetInt(const char *name, int *value)
235
284
236
285
See `PyConfig_GetInt() documentation <https://docs.python.org/dev/c-api/init_config.html#c.PyConfig_GetInt>`__.
237
286
287
+
Not available with the limited C API.
288
+
238
289
.. c:function:: int PyUnstable_Object_IsUniquelyReferenced(PyObject *op)
239
290
240
291
See `PyUnstable_Object_IsUniquelyReferenced() documentation <https://docs.python.org/dev/c-api/object.html#c.PyUnstable_Object_IsUniquelyReferenced>`__.
241
292
242
293
Not available on PyPy. ``Py_REFCNT()`` semantics is different on PyPy.
243
294
295
+
Not available with the limited C API.
296
+
244
297
.. c:function:: int PyUnstable_TryIncRef(PyObject *op)
245
298
246
299
See `PyUnstable_TryIncRef() documentation <https://docs.python.org/dev/c-api/object.html#c.PyUnstable_TryIncRef>`__.
@@ -336,7 +389,7 @@ Python 3.13
336
389
Return non-zero if the Python interpreter is shutting down, return 0
337
390
otherwise.
338
391
339
-
Availability: Python 3.3 and newer, PyPy 7.3 and newer.
392
+
Availability: Python 3.3 and newer, PyPy 7.3 and newer, limited C API 3.13.
340
393
341
394
See `Py_IsFinalizing() documentation <https://docs.python.org/dev/c-api/init.html#c.Py_IsFinalizing>`__.
342
395
@@ -352,15 +405,19 @@ Python 3.13
352
405
353
406
See `PyObject_VisitManagedDict() documentation <https://docs.python.org/dev/c-api/object.html#c.PyObject_VisitManagedDict>`__.
0 commit comments