cpython/Include
Miss Islington (bot) 6a2a2906f8
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
[3.14] GH-133136: Revise QSBR to reduce excess memory held (gh-135473) (#135912)
The free threading build uses QSBR to delay the freeing of dictionary
keys and list arrays when the objects are accessed by multiple threads
in order to allow concurrent reads to proceed with holding the object
lock. The requests are processed in batches to reduce execution
overhead, but for large memory blocks this can lead to excess memory
usage.

Take into account the size of the memory block when deciding when to
process QSBR requests.

Also track the amount of memory being held by QSBR for mimalloc pages.  Advance the write sequence if this memory exceeds a limit.  Advancing the sequence will allow it to be freed more quickly.

Process the held QSBR items from the "eval breaker", rather than from `_PyMem_FreeDelayed()`.  This gives a higher chance that the global read sequence has advanced enough so that items can be freed.

(cherry picked from commit 113de8545f)

Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-07-08 10:58:01 -07:00
..
cpython [3.14] gh-135755: Use private names (_Py*) for header file guards new in 3.14 (GH-135921) (GH-135976) 2025-07-01 12:37:02 +02:00
internal [3.14] GH-133136: Revise QSBR to reduce excess memory held (gh-135473) (#135912) 2025-07-08 10:58:01 -07:00
abstract.h [3.14] gh-134989: Implement PyObject_DelAttr() as a macro in the limited C API (GH-135021) (#135133) 2025-06-04 13:33:20 +00:00
audit.h [3.14] gh-135755: Use private names (_Py*) for header file guards new in 3.14 (GH-135921) (GH-135976) 2025-07-01 12:37:02 +02:00
bltinmodule.h
boolobject.h [3.14] gh-134989: Fix Py_RETURN_NONE in the limited C API (GH-135165) (#135178) 2025-06-05 15:35:54 +02:00
bytearrayobject.h
bytesobject.h
ceval.h [3.14] gh-135755: Move SPECIAL_ constants to a private header (GH-135922) (GH-135926) 2025-06-25 13:36:46 +02:00
codecs.h
compile.h
complexobject.h
critical_section.h
datetime.h
descrobject.h
dictobject.h
dynamic_annotations.h
enumobject.h
errcode.h
exports.h
fileobject.h
fileutils.h
floatobject.h
frameobject.h
genericaliasobject.h
import.h
intrcheck.h
iterobject.h
listobject.h
lock.h
longobject.h gh-132639: Adds PyLong_AsNativeBytes, PyLong_FromNativeBytes and PyLong_FromUnsignedNativeBytes to the limited API (GH-132640) 2025-04-21 15:59:03 +01:00
marshal.h
memoryobject.h
methodobject.h gh-132097: use a macro for semantically casting function pointers (#132406) 2025-04-18 12:24:34 +02:00
modsupport.h
moduleobject.h
monitoring.h
object.h [3.14] gh-134989: Fix Py_RETURN_NONE in the limited C API (GH-135165) (#135178) 2025-06-05 15:35:54 +02:00
objimpl.h
opcode.h gh-100239: replace BINARY_SUBSCR & family by BINARY_OP with oparg NB_SUBSCR (#129700) 2025-02-07 22:39:54 +00:00
opcode_ids.h gh-100239: specialize BINARY_OP/SUBSCR for list-slice (#132626) 2025-05-01 10:28:52 +00:00
osdefs.h
osmodule.h
patchlevel.h Post 3.14.0b4 2025-07-08 17:31:34 +03:00
py_curses.h bpo-44172: Keep reference to original window in curses subwindow objects (GH-26226) 2025-05-04 13:29:44 +03:00
pyatomic.h
pybuffer.h
pycapsule.h
pydtrace.d
pydtrace.h
pyerrors.h
pyexpat.h
pyframe.h
pyhash.h
pylifecycle.h
pymacconfig.h
pymacro.h gh-128972: Add _Py_ALIGN_AS and revert PyASCIIObject memory layout. (GH-133085) 2025-05-02 18:30:40 +02:00
pymath.h
pymem.h
pyport.h gh-133256: Add _Py_NONSTRING macro (#133257) 2025-05-01 17:55:49 +02:00
pystate.h
pystats.h
pystrcmp.h
pystrtod.h
Python.h [3.14] gh-133779: Revert Windows generation of pyconfig.h and go back to a static header. (GH-133966) 2025-05-19 21:24:53 +01:00
pythonrun.h [3.14] gh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers (GH-135928) (#136173) 2025-07-01 13:44:32 +00:00
pythread.h
pytypedefs.h
rangeobject.h
README.rst
refcount.h [3.14] gh-127705: Move Py_INCREF_MORTAL() to the internal C API (GH-136178) (#136206) 2025-07-03 06:42:17 +00:00
setobject.h
sliceobject.h
structmember.h
structseq.h
sysmodule.h gh-125604: Move _Py_AuditHookEntry, etc. Out of pycore_runtime.h (gh-125605) 2024-10-18 09:26:08 -06:00
traceback.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
tupleobject.h
typeslots.h Revert "gh-133395: add option for extension modules to specialize BINARY_OP/SUBSCR, apply to arrays (#133396)" (#133498) 2025-05-06 13:12:26 +03:00
unicodeobject.h gh-132798: Schedule removal of PyUnicode_AsDecoded/Encoded functions for 3.15 (#132799) 2025-04-25 15:07:41 +02:00
warnings.h
weakrefobject.h gh-105927: Limit PyWeakref_GetRef() to limited C API 3.13 (#117091) 2024-03-20 23:52:23 +01:00

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/