cpython/Modules/_testinternalcapi
Sam Gross d891b2bbd1
gh-139103: Improve namedtuple scaling in free-threaded build (gh-144332)
Add `_Py_type_getattro_stackref`, a variant of type attribute lookup
that returns `_PyStackRef` instead of `PyObject*`. This allows returning
deferred references in the free-threaded build, reducing reference count
contention when accessing type attributes.

This significantly improves scaling of namedtuple instantiation across
multiple threads.

* Add blurb

* Rename PyObject_GetAttrStackRef to _PyObject_GetAttrStackRef

* Apply suggestion from @vstinner

Co-authored-by: Victor Stinner <vstinner@python.org>

* Apply suggestion from @vstinner

Co-authored-by: Victor Stinner <vstinner@python.org>

* format

* Update Include/internal/pycore_function.h

Co-authored-by: Victor Stinner <vstinner@python.org>

---------

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-02-06 09:43:05 -05:00
..
clinic gh-110964: Remove private _PyArg functions (#110966) 2023-10-17 14:30:31 +02:00
complex.c gh-128813: hide mixed-mode functions for complex arithmetic from C-API (#131703) 2025-04-22 14:18:18 +02:00
interpreter.c gh-142913: Remove JIT interpreter for interpreter generator tests (GH-143944) 2026-01-17 00:34:39 +00:00
parts.h gh-128813: hide mixed-mode functions for complex arithmetic from C-API (#131703) 2025-04-22 14:18:18 +02:00
pytime.c Remove internal _PyTime_AsLong() function (#141053) 2025-11-05 18:37:06 +01:00
README.txt gh-108777: Split _PyTime tests from _testinternalcapi.c (gh-108787) 2023-09-02 00:46:36 +00:00
set.c gh-112069: Add _PySet_NextEntryRef to be thread-safe. (gh-117990) 2024-04-19 00:18:22 +09:00
test_cases.c.h gh-139103: Improve namedtuple scaling in free-threaded build (gh-144332) 2026-02-06 09:43:05 -05:00
test_critical_sections.c gh-114203: skip locking if object is already locked by two-mutex critical section (#141476) 2025-11-14 23:17:59 +05:30
test_lock.c gh-140263: Fix data race in test_lock_two_threads (gh-140264) 2025-10-20 09:58:05 -04:00
test_targets.h gh-142913: Add test case for interpreter generator w/ overridden opcodes (#142911) 2026-01-16 10:33:29 -08:00
testbytecodes.c gh-142913: Add test case for interpreter generator w/ overridden opcodes (#142911) 2026-01-16 10:33:29 -08:00

Tests in this directory are compiled into the _testinternalcapi extension.
The main file for the extension is Modules/_testinternalcapimodule.c, which
calls `_PyTestInternalCapi_Init_*` from these functions.

See Modules/_testcapi/README.txt for guideline when writing C test code.