cpython/Include
Neil Schemenauer cdba68e563
[3.15] gh-159136: Avoid stop-the-world when setting function name attributes (gh-159269) (gh-159725)
Setting __name__, __qualname__, __doc__ or __module__ on a function
stopped the world in the free-threaded build since gh-154826 and
gh-154851, making functools.wraps() orders of magnitude slower with
multiple threads.

Use the per-object critical section and _PyObject_XSetRefDelayed()
instead, as gen_set_name() already does.  Use acquire loads in the
readers and hold strong references across error reporting, tracing, and
eval-frame recording that may execute Python or detach the thread.  The
__code__, __defaults__, __kwdefaults__ and __closure__ setters still
stop the world to clear func_version.

Document synchronization requirements for direct field access and the
lifetime of borrowed function attributes.

(cherry picked from commit 010bebbf9f)
2026-10-29 15:17:50 -07:00
..
cpython [3.15] gh-159136: Avoid stop-the-world when setting function name attributes (gh-159269) (gh-159725) 2026-10-29 15:17:50 -07:00
internal [3.15] gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112) (gh-160178) 2026-10-22 09:55:05 -07:00
abstract.h gh-134989: Implement PyObject_DelAttr() as a macro in the limited C API (GH-135021) 2025-06-04 15:07:52 +02:00
audit.h gh-135755: Use private names (_Py*) for header file guards new in 3.14 (GH-135921) 2025-06-26 13:05:01 +02:00
bltinmodule.h
boolobject.h
bytearrayobject.h
bytesobject.h
ceval.h
codecs.h Remove private _PyCodec_Lookup() function (#106269) 2023-06-30 09:34:01 +00:00
compile.h
complexobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
critical_section.h gh-149225: Expose Py_CriticalSection in Stable ABI (GH-149227) 2026-05-04 17:32:17 +02:00
datetime.h
descrobject.h
dictobject.h
dynamic_annotations.h
enumobject.h
errcode.h
exports.h gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055) 2026-05-05 09:18:04 +02:00
fileobject.h
fileutils.h
floatobject.h
frameobject.h
genericaliasobject.h
import.h
intrcheck.h
iterobject.h
listobject.h
longobject.h gh-143869: Add PEP 757 functions to the limited API (#143906) 2026-01-21 14:47:14 +01:00
marshal.h
memoryobject.h
methodobject.h
modsupport.h [3.15] gh-140550: Fix PyABIInfo_VAR macro: avoid ";" (#157494) 2026-09-15 16:24:49 +03:00
moduleobject.h
object.h [3.15] gh-155503: Add more PyType C API tests (#155505) (#159085) 2026-10-09 20:33:40 +00:00
objimpl.h
opcode.h
opcode_ids.h GH-143732: SEND specialization (GH-148963) 2026-05-05 15:19:16 +01:00
osdefs.h gh-108765: Reformat Include/osdefs.h (#108766) 2023-09-01 14:35:39 +00:00
osmodule.h Issue #29058: All stable API extensions added after Python 3.2 are now 2016-12-27 14:57:39 +02:00
patchlevel.h Post 3.15.2 2026-10-26 06:18:53 +02:00
py_curses.h [3.15] gh-152502: Detect the curses mouse interface portably (GH-152705) (GH-152707) 2026-06-30 23:59:28 +03:00
pyabi.h gh-148690: Build Windows freethreaded binaries into separate directory and include python3t.dll on GIL-enabled (GH-149218) 2026-05-04 17:45:08 +01:00
pyatomic.h gh-108724: Add PyMutex and _PyParkingLot APIs (gh-109344) 2023-09-19 09:54:29 -06:00
pybuffer.h gh-137696: Rename 'fort' parameter to 'order' in PyBuffer_* functions (#137866) 2026-03-19 16:54:27 +05:30
pycapsule.h gh-108240: Add pycore_capsule.h internal header file (#108596) 2023-08-29 01:20:02 +00:00
pydtrace.d bpo-36842: Implement PEP 578 (GH-12613) 2019-05-23 08:45:22 -07:00
pydtrace.h Fix pydtrace.d path comment in Include/pydtrace.h (#28539) 2022-12-31 22:40:25 +05:30
pyerrors.h gh-142349: Implement PEP 810 - Explicit lazy imports (#142351) 2026-02-12 00:15:33 +00:00
pyexpat.h [3.15] gh-149018: Use XML_SetHashSalt16Bytes in pyexpat/_elementtree when possible (#149645) 2026-05-24 14:36:30 +01:00
pyframe.h gh-93937, C API: Move PyFrame_GetBack() to Python.h (#93938) 2022-06-19 12:02:33 +02:00
pyhash.h
pylifecycle.h
pymacconfig.h
pymacro.h [3.15] gh-160704: Restore C11-C17 static_assert fallback (GH-160705) (GH-160825) 2026-10-28 14:56:04 +00:00
pymath.h
pymem.h gh-85283: Add PyMem_RawMalloc() to the limited C API (#108570) 2023-10-17 02:41:51 +02:00
pyport.h [3.15] gh-160208: Add a private wrapper around __STDC_VERSION__ (GH-160376) (GH-160437) 2026-10-23 20:31:48 +02:00
pystate.h gh-149101: Implement PEP 788 (GH-149116) 2026-05-06 17:39:30 -04:00
pystats.h
pystrcmp.h Merged revisions 59541-59561 via svnmerge from 2007-12-19 02:07:34 +00:00
pystrtod.h
Python.h gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055) 2026-05-05 09:18:04 +02:00
pythonrun.h
pythread.h
pytypedefs.h gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055) 2026-05-05 09:18:04 +02:00
rangeobject.h
README.rst
refcount.h [3.15] gh-157649: Fix Py_CLEAR()/Py_SETREF() on C++ (#159143) 2026-10-10 20:31:36 +00:00
setobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
sliceobject.h [3.15] gh-149685: Use the _Py prefix for private C macros (GH-149686) (GH-149790) 2026-05-13 23:29:08 +02:00
slots.h [3.15] gh-149044: Avoid C++ warnings in PySlot_END macro (GH-158866) (#158965) 2026-10-09 22:11:17 +02:00
slots_generated.h gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055) 2026-05-05 09:18:04 +02:00
structmember.h
structseq.h
sysmodule.h gh-138886: Remove deprecated PySys_ResetWarnOptions C-API function (#138887) 2025-09-15 12:01:33 +03:00
traceback.h
tupleobject.h
unicodeobject.h gh-146175: Soft-deprecate outdated macros; convert internal usage (GH-146178) 2026-03-23 12:42:09 +01:00
warnings.h
weakrefobject.h

The Python C API
================

The C API is divided into these sections:

1. ``Include/``: Limited API
2. ``Include/cpython/``: CPython implementation details
3. ``Include/cpython/``, names with the ``PyUnstable_`` prefix: API that can
   change between minor releases
4. ``Include/internal/``, and any name with ``_`` prefix: The internal API

Information on changing the C API is available `in the developer guide`_

.. _in the developer guide: https://devguide.python.org/c-api/