Tin mới
Python support for free threading
Remote debugging attachment protocol
Starting with the 3.13 release, CPython has support for running with the global interpreter lock (GIL) disabled in a configuration called free threading. This document describes how to adapt C API extensions to support f
On Windows, this macro is not defined automatically, but must be specified to the compiler when building. The sysconfig.get_config_var() function can be used to determine whether the current running interpreter had the m
Extensions that use multi-phase initialization (i.e., PyModuleDef_Init()) should add a Py_mod_gil slot in the module definition. If your extension supports older versions of CPython, you should guard the slot with a PY_V
Extensions that use multi-phase initialization (i.e., PyModuleDef_Init()) should add a Py_mod_gil slot in the module definition. If your extension supports older versions of CPython, you should guard the slot with a PY_V
Extensions that use multi-phase initialization (i.e., PyModuleDef_Init()) should add a Py_mod_gil slot in the module definition. If your extension supports older versions of CPython, you should guard the slot with a PY_V
Macros: Accessor macros like PyList_GET_ITEM, PyList_SET_ITEM, and macros like PySequence_Fast_GET_SIZE that use the object returned by PySequence_Fast() do not perform any error checking or locking. These macros are not
Containers like PyListObject, PyDictObject, and PySetObject perform internal locking in the free-threaded build. For example, the PyList_Append() will lock the list before appending an item.
Containers like PyListObject, PyDictObject, and PySetObject perform internal locking in the free-threaded build. For example, the PyList_Append() will lock the list before appending an item.
Containers like PyListObject, PyDictObject, and PySetObject perform internal locking in the free-threaded build. For example, the PyList_Append() will lock the list before appending an item.
A notable exception is PyDict_Next(), which does not lock the dictionary. You should use Py_BEGIN_CRITICAL_SECTION to protect the dictionary while iterating over it if the dictionary may be concurrently modified:
Some C API functions return borrowed references. These APIs are not thread-safe if the containing object is modified concurrently. For example, it’s not safe to use PyList_GetItem() if the list may be modified concurrent
Python’s memory management C API provides functions in three different allocation domains: “raw”, “mem”, and “object”. For thread-safety, the free-threaded build requires that only Python objects are allocated using the
The free-threaded build does not currently support the Limited C API or the stable ABI. If you use setuptools to build your extension and currently set py_limited_api=True you can use py_limited_api=not sysconfig.get_con