summaryrefslogtreecommitdiffstats
path: root/Include/cpython
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-120838: Add _PyThreadState_WHENCE_FINI (gh-121013)Miss Islington (bot)2024-06-261-4/+5
| | | | | | | | | We also add _PyThreadState_NewBound() and drop _PyThreadState_SetWhence(). This change only affects internal API. (cherry picked from commit a905721b9c5c15279e67c2f7785034b7356b2d46, AKA gh-121010) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* [3.13] gh-120593: Fix const qualifier in pyatomic.h (GH-121055) (#121057)Miss Islington (bot)2024-06-261-4/+4
| | | | | | gh-120593: Fix const qualifier in pyatomic.h (GH-121055) (cherry picked from commit 9cd2dcbb87fb3c35d8ca3554d9472ac283f62a64) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-120642: Move private PyCode APIs to the internal C API (#120643) ↵Victor Stinner2024-06-262-216/+0
| | | | | | | | | | | | | | | | | | | | | (#121043) gh-120642: Move private PyCode APIs to the internal C API (#120643) * Move _Py_CODEUNIT and related functions to pycore_code.h. * Move _Py_BackoffCounter to pycore_backoff.h. * Move Include/cpython/optimizer.h content to pycore_optimizer.h. * Remove Include/cpython/optimizer.h. * Remove PyUnstable_Replace_Executor(). Rename functions: * PyUnstable_GetExecutor() => _Py_GetExecutor() * PyUnstable_GetOptimizer() => _Py_GetOptimizer() * PyUnstable_SetOptimizer() => _Py_SetTier2Optimizer() * PyUnstable_Optimizer_NewCounter() => _PyOptimizer_NewCounter() * PyUnstable_Optimizer_NewUOpOptimizer() => _PyOptimizer_NewUOpOptimizer() (cherry picked from commit 9e4a81f00fef689c6e18a64245aa064eaadc7ac7)
* [3.13] gh-119344: Make critical section API public (GH-119353) (#120856)Sam Gross2024-06-211-0/+134
| | | | | | | | | | | This makes the following macros public as part of the non-limited C-API for locking a single object or two objects at once. * `Py_BEGIN_CRITICAL_SECTION(op)` / `Py_END_CRITICAL_SECTION()` * `Py_BEGIN_CRITICAL_SECTION2(a, b)` / `Py_END_CRITICAL_SECTION2()` The supporting functions and structs used by the macros are also exposed for cases where C macros are not available. (cherry picked from commit 8f17d69b7bc906e8407095317842cc0fd52cd84a)
* [3.13] gh-117511: Make PyMutex public in the non-limited API (GH-117731) ↵Sam Gross2024-06-202-1/+64
| | | | | (#120800) (cherry picked from commit 3af7263037de1d0ef63b070fc7bfc2cf042eaebe)
* [3.13] gh-118789: Add `PyUnstable_Object_ClearWeakRefsNoCallbacks` ↵Miss Islington (bot)2024-06-181-0/+2
| | | | | | | | | | | | | | | | | (GH-118807) (#120695) This exposes `PyUnstable_Object_ClearWeakRefsNoCallbacks` as an unstable C-API function to provide a thread-safe mechanism for clearing weakrefs without executing callbacks. Some C-API extensions need to clear weakrefs without calling callbacks, such as after running finalizers like we do in subtype_dealloc. Previously they could use `_PyWeakref_ClearRef` on each weakref, but that's not thread-safe in the free-threaded build. (cherry picked from commit e8752d7b80775ec2a348cd4bf38cbe26a4a07615) Co-authored-by: Sam Gross <colesbury@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* [3.13] gh-111389: Add PyHASH_MULTIPLIER constant (GH-119214) (#119334)Miss Islington (bot)2024-06-041-2/+3
| | | | | | gh-111389: Add PyHASH_MULTIPLIER constant (GH-119214) (cherry picked from commit f6da790122fdae1a28f444edfbb55202d6829cd1) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-119336: Restore removed _PyLong_NumBits() function (GH-119418) ↵Miss Islington (bot)2024-06-031-0/+9
| | | | | | | | | | (#119970) gh-119336: Restore removed _PyLong_NumBits() function (GH-119418) It is used by the pywin32 project. (cherry picked from commit e50fac96e82d857ecc024b4cd4e012493b077064) Co-authored-by: Ethan Smith <ethan@ethanhs.me>
* [3.13] gh-118692: Avoid creating unnecessary StopIteration instances for ↵Miss Islington (bot)2024-05-241-3/+3
| | | | | | | | | | monitoring (GH-119216) (#119497) * gh-118692: Avoid creating unnecessary StopIteration instances for monitoring (GH-119216) (cherry picked from commit 6e9863d7a3516cc76d6ce13923b15620499f3855) --------- Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* [3.13] gh-118727: Don't drop the GIL in `drop_gil()` unless the current ↵Miss Islington (bot)2024-05-231-1/+3
| | | | | | | | | | | | | | | | | | | | thread holds it (GH-118745) (#119474) `drop_gil()` assumes that its caller is attached, which means that the current thread holds the GIL if and only if the GIL is enabled, and the enabled-state of the GIL won't change. This isn't true, though, because `detach_thread()` calls `_PyEval_ReleaseLock()` after detaching and `_PyThreadState_DeleteCurrent()` calls it after removing the current thread from consideration for stop-the-world requests (effectively detaching it). Fix this by remembering whether or not a thread acquired the GIL when it last attached, in `PyThreadState._status.holds_gil`, and check this in `drop_gil()` instead of `gil->enabled`. This fixes a crash in `test_multiprocessing_pool_circular_import()`, so I've reenabled it. (cherry picked from commit be1dfccdf2c5c7671b8a549e969b8cf7d60d9936) Co-authored-by: Brett Simmers <swtaarrs@users.noreply.github.com>
* [3.13] gh-118789: Restore hidden `_PyWeakref_ClearRef` (GH-118797) (GH-118903)Miss Islington (bot)2024-05-101-0/+2
| | | | | | | | | | | | | | | gh-118789: Restore hidden `_PyWeakref_ClearRef` (GH-118797) _PyWeakref_ClearRef was previously exposed in the public C-API, although it begins with an underscore and is not documented. It's used by a few C-API extensions. There is currently no alternative public API that can replace its use. _PyWeakref_ClearWeakRefsExceptCallbacks is the only thread-safe way to use _PyWeakref_ClearRef in the free-threaded build. This exposes the C symbol, but does not make the API public. (cherry picked from commit db5af7da092409030c9fbe0a3a986bd0ee441b8b) Co-authored-by: Sam Gross <colesbury@gmail.com>
* gh-112075: use per-thread dict version pool (#118676)Dino Viehland2024-05-071-0/+1
| | | use thread state set of dict versions
* GH-115709: Invalidate executors when a local variable is changed via ↵Mark Shannon2024-05-061-3/+9
| | | | | frame.f_locals (#118639) Also fix unrelated assert in debug Tier2/JIT builds.
* gh-118362: Fix thread safety around lookups from the type cache in the face ↵Dino Viehland2024-05-065-0/+29
| | | | | | | of concurrent mutators (#118454) Add _PyType_LookupRef and use incref before setting attribute on type Makes setting an attribute on a class and signaling type modified atomic Avoid adding re-entrancy exposing the type cache in an inconsistent state by decrefing after type is updated
* gh-74929: Implement PEP 667 (GH-115153)Tian Gao2024-05-042-0/+8
|
* gh-111997: C-API for signalling monitoring events (#116413)Irit Katriel2024-05-041-0/+250
|
* gh-93502: Add new C-API functions to trace object creation and destruction ↵Pablo Galindo Salgado2024-05-021-0/+10
| | | | (#115945)
* GH-117442: Check eval-breaker at start (rather than end) of tier 2 loops ↵Mark Shannon2024-05-021-1/+1
| | | | (GH-118482)
* gh-110850: Add PyTime_TimeRaw() function (#118394)Victor Stinner2024-05-011-0/+4
| | | | | | | | | | | | | | | | | Add "Raw" variant of PyTime functions: * PyTime_MonotonicRaw() * PyTime_PerfCounterRaw() * PyTime_TimeRaw() Changes: * Add documentation and tests. Tests release the GIL while calling raw clock functions. * py_get_system_clock() and py_get_monotonic_clock() now check that the GIL is hold by the caller if raise_exc is non-zero. * Reimplement "Unchecked" functions with raw clock functions. Co-authored-by: Petr Viktorin <encukou@gmail.com>
* GH-115802: Use the GHC calling convention in JIT code (GH-118287)Brandt Bucher2024-05-011-0/+1
|
* gh-116767: fix crash on 'async with' with many context managers (GH-118348)Irit Katriel2024-05-011-1/+1
| | | | | | | Account for `add_stopiteration_handler` pushing a block for `async with`. To allow generator functions that previously almost hit the `CO_MAXBLOCKS` limit by nesting non-async blocks, the limit is increased by 1. This increase allows one more block in non-generator functions.
* GH-118095: Make invalidating and clearing executors memory safe (GH-118459)Mark Shannon2024-05-011-1/+2
|
* gh-118331: Handle errors in _PyObject_SetManagedDict (#118334)Sam Gross2024-04-291-1/+1
| | | | | When detaching a dict, the `copy_values` call may fail due to out-of-memory errors. This can be triggered by test_no_memory in test_repl.
* gh-117657: Fixes a few small TSAN issues in dictobject (#118200)Dino Viehland2024-04-251-0/+4
| | | | Fixup TSAN errors for dict
* gh-118207: Rename the COMMON_FIELDS macro in funcobject.h and undef it after ↵Itamar Oren2024-04-251-3/+5
| | | | use (GH-118208)
* gh-112075: Make instance attributes stored in inline "dict" thread safe ↵Dino Viehland2024-04-221-0/+1
| | | | | (#114742) Make instance attributes stored in inline "dict" thread safe on free-threaded builds
* gh-116818: Make `sys.settrace`, `sys.setprofile`, and monitoring thread-safe ↵Dino Viehland2024-04-194-0/+57
| | | | | | | (#116775) Makes sys.settrace, sys.setprofile, and monitoring generally thread-safe. Mostly uses a stop-the-world approach and synchronization around the code object's _co_instrumentation_version. There may be a little bit of extra synchronization around the monitoring data that's required to be TSAN clean.
* gh-112069: Make PySet_GET_SIZE to be atomic safe. (gh-118053)Donghee Na2024-04-181-0/+4
| | | gh-112069: Make PySet_GET_SIZE to be atomic operation
* GH-117760: Streamline the trashcan mechanism (GH-117763)Mark Shannon2024-04-172-28/+26
|
* gh-117645: Increase WASI stack size from 512 KiB to 8 MiB (#117674)Victor Stinner2024-04-161-8/+3
| | | | | Increase also the initial memory from 10 MiB to 20 MiB. Reenable test_dynamic on WASI build.
* gh-115178: Add Counts of UOp Pairs to pystats (GH-115181)Jeff Glass2024-04-161-0/+1
|
* gh-117649: Raise ImportError for unsupported modules in free-threaded build ↵Sam Gross2024-04-111-1/+10
| | | | | | | | | | (#117651) The free-threaded build does not currently support the combination of single-phase init modules and non-isolated subinterpreters. Ensure that `check_multi_interp_extensions` is always `True` for subinterpreters in the free-threaded build so that importing these modules raises an `ImportError`.
* gh-111926: Make weakrefs thread-safe in free-threaded builds (#117168)mpage2024-04-081-0/+8
| | | | | | | | | Most mutable data is protected by a striped lock that is keyed on the referenced object's address. The weakref's hash is protected using the weakref's per-object lock. Note that this only affects free-threaded builds. Apart from some minor refactoring, the added code is all either gated by `ifdef`s or is a no-op (e.g. `Py_BEGIN_CRITICAL_SECTION`).
* gh-111140: PyLong_From/AsNativeBytes: Take *flags* rather than just ↵Steve Dower2024-04-051-5/+19
| | | | *endianness* (GH-116053)
* gh-116968: Reimplement Tier 2 counters (#117144)Guido van Rossum2024-04-042-14/+12
| | | | | | | | | | | | Introduce a unified 16-bit backoff counter type (``_Py_BackoffCounter``), shared between the Tier 1 adaptive specializer and the Tier 2 optimizer. The API used for adaptive specialization counters is changed but the behavior is (supposed to be) identical. The behavior of the Tier 2 counters is changed: - There are no longer dynamic thresholds (we never varied these). - All counters now use the same exponential backoff. - The counter for ``JUMP_BACKWARD`` starts counting down from 16. - The ``temperature`` in side exits starts counting down from 64.
* GH-115776: Embed the values array into the object, for "normal" Python ↵Mark Shannon2024-04-021-2/+1
| | | | objects. (GH-116115)
* gh-117411: move PyFutureFeatures to pycore_symtable.h and make it private ↵Irit Katriel2024-04-021-20/+0
| | | | (#117412)
* GH-116422: Tier2 hot/cold splitting (GH-116813)Mark Shannon2024-03-261-2/+49
| | | | | Splits the "cold" path, deopts and exits, from the "hot" path, reducing the size of most jitted instructions, at the cost of slower exits.
* A few minor tweaks to get stats working and compiling cleanly. (#117219)Mark Shannon2024-03-251-2/+2
| | | | Fixes a compilation error when configured with `--enable-pystats`, an array size issue, and an unused variable.
* gh-116936: Add PyType_GetModuleByDef() to the limited C API (#116937)Victor Stinner2024-03-251-1/+0
|
* gh-117008: Fix functools test_recursive_pickle() (#117009)Victor Stinner2024-03-231-0/+2
| | | | | | | Use support.infinite_recursion() in test_recursive_pickle() of test_functools to prevent a stack overflow on "ARM64 Windows Non-Debug" buildbot. Lower Py_C_RECURSION_LIMIT to 1,000 frames on Windows ARM64.
* gh-113024: C API: Add PyObject_GenericHash() function (GH-113025)Serhiy Storchaka2024-03-221-0/+1
|
* gh-71052: Add Android build script and instructions (#116426)Malcolm Smith2024-03-211-0/+4
|
* gh-116996: Add pystats about _Py_uop_analyse_and_optimize (GH-116997)Michael Droettboom2024-03-211-1/+6
|
* gh-76785: Drop PyInterpreterID_Type (gh-117101)Eric Snow2024-03-211-14/+0
| | | I added it quite a while ago as a strategy for managing interpreter lifetimes relative to the PEP 554 (now 734) implementation. Relatively recently I refactored that implementation to no longer rely on InterpreterID objects. Thus now I'm removing it.
* gh-76785: Clean Up Interpreter ID Conversions (gh-117048)Eric Snow2024-03-211-1/+4
| | | Mostly we unify the two different implementations of the conversion code (from PyObject * to int64_t. We also drop the PyArg_ParseTuple()-style converter function, as well as rename and move PyInterpreterID_LookUp().
* gh-115756: make PyCode_GetFirstFree an unstable API (GH-115781)Bogdan Romanyuk2024-03-191-1/+5
|
* gh-116941: Fix pyatomic_std.h syntax errors (#116967)Sam Gross2024-03-181-0/+2
|
* gh-116869: Make C API compatible with ISO C90 (#116950)Victor Stinner2024-03-181-1/+2
| | | | Make the C API compatible with -Werror=declaration-after-statement compiler flag again.
* gh-116869: Fix redefinition of the _PyOptimizerObject type (#116963)Victor Stinner2024-03-181-2/+2
| | | | | | | | | | | | | | | Defining a type twice is a C11 feature and so makes the C API incompatible with C99. Fix the issue by only defining the type once. Example of warning (treated as an error): In file included from Include/Python.h:122: Include/cpython/optimizer.h:77:3: error: redefinition of typedef '_PyOptimizerObject' is a C11 feature [-Werror,-Wtypedef-redefinition] } _PyOptimizerObject; ^ build/Include/cpython/optimizer.h:60:35: note: previous definition is here typedef struct _PyOptimizerObject _PyOptimizerObject; ^