summaryrefslogtreecommitdiffstats
path: root/Include
Commit message (Collapse)AuthorAgeFilesLines
* GH-125837: Split `LOAD_CONST` into three. (GH-125972)Mark Shannon2024-10-296-104/+136
| | | | | | | | * Add LOAD_CONST_IMMORTAL opcode * Add LOAD_SMALL_INT opcode * Remove RETURN_CONST opcode
* GH-125515: Reduce number of compiler warnings in generated code (GH-125697)Mark Shannon2024-10-281-3/+3
|
* gh-121654: Add PyType_Freeze() function (#122457)Victor Stinner2024-10-251-0/+4
| | | Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-125900: Clean-up logic around immortalization in free-threading (#125901)Sam Gross2024-10-242-8/+3
| | | | | | | | | * Remove `@suppress_immortalization` decorator * Make suppression flag per-thread instead of per-interpreter * Suppress immortalization in `eval()` to avoid refleaks in three tests (test_datetime.test_roundtrip, test_logging.test_config8_ok, and test_random.test_after_fork). * frozenset() is constant, but not a singleton. When run multiple times, the test could fail due to constant interning.
* gh-123930: Better error for "from imports" when script shadows module (#123929)Shantanu2024-10-241-0/+2
|
* gh-124218: Avoid refcount contention on builtins module (GH-125847)Sam Gross2024-10-242-3/+29
| | | | | | | This replaces `_PyEval_BuiltinsFromGlobals` with `_PyDict_LoadBuiltinsFromGlobals`, which returns a new reference instead of a borrowed reference. Internally, the new function uses per-thread reference counting when possible to avoid contention on the refcount fields on the builtins module.
* gh-125859: Fix crash when `gc.get_objects` is called during GC (#125882)Sam Gross2024-10-241-0/+10
| | | | | | | | | This fixes a crash when `gc.get_objects()` or `gc.get_referrers()` is called during a GC in the free threading build. Switch to `_PyObjectStack` to avoid corrupting the `struct worklist` linked list maintained by the GC. Also, don't return objects that are frozen (`gc.freeze()`) or in the process of being collected to more closely match the behavior of the default build.
* gh-124218: Use per-thread reference counting for globals and builtins (#125713)Sam Gross2024-10-214-1/+54
| | | | Use per-thread refcounting for the reference from function objects to the globals and builtins dictionaries.
* gh-119311: Add missing magic number (3571) for 3.13.0b1 (#125771)Lumír 'Frenzy' Balhar2024-10-211-0/+1
| | | | | Add missing magic number 3571 for 3.13b1 It was added after branching in https://github.com/python/cpython/commit/6394a72e99b342d980297ec437ecafea92a044c4#diff-efefe383b3a81d16150c280db0b64eed7569254299418f64cc0d749f8e16f3a4R475
* gh-125703: Correctly honour tracemalloc hooks on specialized DECREF paths ↵Pablo Galindo Salgado2024-10-181-0/+5
| | | | (#125704)
* gh-125604: Move _Py_AuditHookEntry, etc. Out of pycore_runtime.h (gh-125605)Eric Snow2024-10-1812-332/+390
| | | | | | | | | | | | This is essentially a cleanup, moving a handful of API declarations to the header files where they fit best, creating new ones when needed. We do the following: * add pycore_debug_offsets.h and move _Py_DebugOffsets, etc. there * inline struct _getargs_runtime_state and struct _gilstate_runtime_state in _PyRuntimeState * move struct _reftracer_runtime_state to the existing pycore_object_state.h * add pycore_audit.h and move to it _Py_AuditHookEntry , _PySys_Audit(), and _PySys_ClearAuditHooks * add audit.h and cpython/audit.h and move the existing audit-related API there *move the perfmap/trampoline API from cpython/sysmodule.h to cpython/ceval.h, and remove the now-empty cpython/sysmodule.h
* gh-125444: Fix illegal instruction for older Arm architectures (#125574)Diego Russo2024-10-162-3/+3
| | | | | | | | On Arm v5 it is not possible to get the thread ID via c13 register hence the illegal instruction. The c13 register started to provide thread ID since Arm v6K architecture variant. Other variants of Arm v6 (T2, Z and base) don’t provide the thread ID via c13. For the sake of simplicity we group v5 and v6 together and consider that instructions for Arm v7 only.
* gh-124872: Replace enter/exit events with "switched" (#125532)Kirill Podoprigora2024-10-161-13/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Users want to know when the current context switches to a different context object. Right now this happens when and only when a context is entered or exited, so the enter and exit events are synonymous with "switched". However, if the changes proposed for gh-99633 are implemented, the current context will also switch for reasons other than context enter or exit. Since users actually care about context switches and not enter or exit, replace the enter and exit events with a single switched event. The former exit event was emitted just before exiting the context. The new switched event is emitted after the context is exited to match the semantics users expect of an event with a past-tense name. If users need the ability to clean up before the switch takes effect, another event type can be added in the future. It is not added here because YAGNI. I skipped 0 in the enum as a matter of practice. Skipping 0 makes it easier to troubleshoot when code forgets to set zeroed memory, and it aligns with best practices for other tools (e.g., https://protobuf.dev/programming-guides/dos-donts/#unspecified-enum). Co-authored-by: Richard Hansen <rhansen@rhansen.org> Co-authored-by: Victor Stinner <vstinner@python.org>
* Post 3.14.0a1Hugo van Kemenade2024-10-151-1/+1
|
* Python 3.14.0a1v3.14.0a1Hugo van Kemenade2024-10-151-2/+2
|
* gh-124218: Use per-thread refcounts for code objects (#125216)Sam Gross2024-10-154-35/+58
| | | | | | | Use per-thread refcounting for the reference from function objects to their corresponding code object. This can be a source of contention when frequently creating nested functions. Deferred refcounting alone isn't a great fit here because these references are on the heap and may be modified by other libraries.
* gh-92953: Improve nextpool/prevpool comment. (gh-125545)Neil Schemenauer2024-10-151-2/+2
| | | | The meaning of these links depends on which list the pool is part of. They are only the same size class if on the "usedpools" list.
* gh-125512: Revert "gh-124872: Replace enter/exit events with "switched" ↵Kirill Podoprigora2024-10-151-4/+13
| | | | (#124776)" (#125513)
* gh-124872: Replace enter/exit events with "switched" (#124776)Richard Hansen2024-10-141-13/+4
| | | | | | | | | | | | | | | | | | | | | | Users want to know when the current context switches to a different context object. Right now this happens when and only when a context is entered or exited, so the enter and exit events are synonymous with "switched". However, if the changes proposed for gh-99633 are implemented, the current context will also switch for reasons other than context enter or exit. Since users actually care about context switches and not enter or exit, replace the enter and exit events with a single switched event. The former exit event was emitted just before exiting the context. The new switched event is emitted after the context is exited to match the semantics users expect of an event with a past-tense name. If users need the ability to clean up before the switch takes effect, another event type can be added in the future. It is not added here because YAGNI. I skipped 0 in the enum as a matter of practice. Skipping 0 makes it easier to troubleshoot when code forgets to set zeroed memory, and it aligns with best practices for other tools (e.g., https://protobuf.dev/programming-guides/dos-donts/#unspecified-enum).
* GH-125323: Convert DECREF_INPUTS_AND_REUSE_FLOAT into a function that takes ↵Mark Shannon2024-10-144-6/+15
| | | | PyStackRefs. (GH-125439)
* gh-125139: use `_PyRecursiveMutex` in `_thread.RLock` (#125144)Kumar Aditya2024-10-141-1/+2
|
* gh-125323: Remove some unsafe Py_DECREFs in bytecodes.c, replacing them with ↵Ken Jin2024-10-141-0/+3
| | | | PyStackRef_CLOSEs (GH-125324)
* fix comment in _PyMutex_TryUnlock (#125319)Kumar Aditya2024-10-131-2/+2
|
* gh-124872: Change PyContext_WatchCallback to take PyObject (#124737)Richard Hansen2024-10-121-1/+1
| | | | | The PyContext struct is not intended to be public, and users of the API don't need anything more specific than PyObject. Also see gh-78943.
* gh-111924: use atomics for interp id refcounting (#125321)Kumar Aditya2024-10-121-4/+2
|
* gh-125268: Use static string for "1e309" in AST (#125272)Sam Gross2024-10-105-3/+7
| | | | | When formatting the AST as a string, infinite values are replaced by 1e309, which evaluates to infinity. The initialization of this string replacement was not thread-safe in the free threading build.
* GH-125174: Make immortal objects more robust, following design from PEP 683 ↵Mark Shannon2024-10-104-49/+31
| | | | (GH-125251)
* gh-125196: Add a free list to PyUnicodeWriter (#125227)Victor Stinner2024-10-101-0/+2
|
* gh-124872: Refine contextvars documentation (#124773)Richard Hansen2024-10-091-6/+17
| | | | | | | | | | | | | * Add definitions for "context", "current context", and "context management protocol". * Update related definitions to be consistent with the new definitions. * Restructure the documentation for the `contextvars.Context` class to prepare for adding context manager support, and for consistency with the definitions. * Use `testcode` and `testoutput` to test the `Context.run` example. * Expand the documentation for the `Py_CONTEXT_EVENT_ENTER` and `Py_CONTEXT_EVENT_EXIT` events to clarify and to prepare for planned changes.
* gh-115999: Refactor `LOAD_GLOBAL` specializations to avoid reloading ↵mpage2024-10-093-115/+130
| | | | | | | | | | | | | | | | | | {globals, builtins} keys (gh-124953) Each of the `LOAD_GLOBAL` specializations is implemented roughly as: 1. Load keys version. 2. Load cached keys version. 3. Deopt if (1) and (2) don't match. 4. Load keys. 5. Load cached index into keys. 6. Load object from (4) at offset from (5). This is not thread-safe in free-threaded builds; the keys object may be replaced in between steps (3) and (4). This change refactors the specializations to avoid reloading the keys object and instead pass the keys object from guards to be consumed by downstream uops.
* GH-120024: Tidy up pycore_stackref.h, splitting into GIL and free-threading ↵Mark Shannon2024-10-091-101/+65
| | | | sections (GH-125095)
* gh-124502: Remove _PyUnicode_EQ() function (#125114)Victor Stinner2024-10-091-5/+1
| | | | | | * Replace unicode_compare_eq() with unicode_eq(). * Use unicode_eq() in setobject.c. * Replace _PyUnicode_EQ() with _PyUnicode_Equal(). * Remove unicode_compare_eq() and _PyUnicode_EQ().
* gh-125063: Emit slices as constants in the bytecode compiler (#125064)Michael Droettboom2024-10-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | * Make slices marshallable * Emit slices as constants * Update Python/marshal.c Co-authored-by: Peter Bierma <zintensitydev@gmail.com> * Refactor codegen_slice into two functions so it always has the same net effect * Fix for free-threaded builds * Simplify marshal loading of slices * Only return SUCCESS/ERROR from codegen_slice --------- Co-authored-by: Mark Shannon <mark@hotpy.org> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* gh-115999: Stop the world when invalidating function versions (#124997)mpage2024-10-082-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Stop the world when invalidating function versions The tier1 interpreter specializes `CALL` instructions based on the values of certain function attributes (e.g. `__code__`, `__defaults__`). The tier1 interpreter uses function versions to verify that the attributes of a function during execution of a specialization match those seen during specialization. A function's version is initialized in `MAKE_FUNCTION` and is invalidated when any of the critical function attributes are changed. The tier1 interpreter stores the function version in the inline cache during specialization. A guard is used by the specialized instruction to verify that the version of the function on the operand stack matches the cached version (and therefore has all of the expected attributes). It is assumed that once the guard passes, all attributes will remain unchanged while executing the rest of the specialized instruction. Stopping the world when invalidating function versions ensures that all critical function attributes will remain unchanged after the function version guard passes in free-threaded builds. It's important to note that this is only true if the remainder of the specialized instruction does not enter and exit a stop-the-world point. We will stop the world the first time any of the following function attributes are mutated: - defaults - vectorcall - kwdefaults - closure - code This should happen rarely and only happens once per function, so the performance impact on majority of code should be minimal. Additionally, refactor the API for manipulating function versions to more clearly match the stated semantics.
* gh-90102: Remove isatty call during regular open (#124922)Cody Maloney2024-10-084-0/+7
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-124502: Add PyUnicode_Equal() function (#124504)Victor Stinner2024-10-071-0/+4
|
* GH-121459: Streamline PyObject* to PyStackRef conversions by disallowing ↵Mark Shannon2024-10-071-5/+9
| | | | NULL pointers. (GH-124894)
* GH-119866: Spill the stack around escaping calls. (GH-124392)Mark Shannon2024-10-075-155/+161
| | | | | | | * Spill the evaluation around escaping calls in the generated interpreter and JIT. * The code generator tracks live, cached values so they can be saved to memory when needed. * Spills the stack pointer around escaping calls, so that the exact stack is visible to the cycle GC.
* GH-116968: Remove branch from advance_backoff_counter (GH-124469)Mark Shannon2024-10-071-25/+21
|
* gh-87135: Hang non-main threads that attempt to acquire the GIL during ↵Jeremy Maitin-Shepard2024-10-022-1/+33
| | | | | | | finalization (GH-105805) Instead of surprise crashes and memory corruption, we now hang threads that attempt to re-enter the Python interpreter after Python runtime finalization has started. These are typically daemon threads (our long standing mis-feature) but could also be threads spawned by extension modules that then try to call into Python. This marks the `PyThread_exit_thread` public C API as deprecated as there is no plausible safe way to accomplish that on any supported platform in the face of things like C++ code with finalizers anywhere on a thread's stack. Doing this was the least bad option. Co-authored-by: Gregory P. Smith <greg@krypto.org>
* gh-111178: Fix function signatures in longobject.c (#124895)Victor Stinner2024-10-021-0/+3
| | | | | | | | | | | | | | * Add _PyLong_CAST() macro. * Move forward declarations to the top of longobject.c. * Change long_add(), long_sub(), long_mul(), long_neg(), long_lshift(), long_abs() to take PyLongObject* and return PyLongObject*. Avoid CHECK_BINOP() test. * Add long_add_method(), long_sub_method(), long_mul_method(), long_neg_method(), long_lshift_method(), and long_abs_method() which take PyObject* and return PyObject*. Implement CHECK_BINOP() test. * Add long_lshift_int64() function. * _PyLong_DivmodNear() calls long_lshift_int64(obj, 1) instead of long_lshift_obj(obj, one).
* gh-111178: Fix function signatures in weakrefobject.c (#124903)Victor Stinner2024-10-021-5/+5
|
* gh-111178: Fix function signatures in moduleobject.c (#124900)Victor Stinner2024-10-021-1/+1
|
* gh-116750: Add clear_tool_id function to unregister events and callbacks ↵Tian Gao2024-10-012-0/+5
| | | | (#124568)
* gh-124218: Refactor per-thread reference counting (#124844)Sam Gross2024-10-015-86/+83
| | | | | | | Currently, we only use per-thread reference counting for heap type objects and the naming reflects that. We will extend it to a few additional types in an upcoming change to avoid scaling bottlenecks when creating nested functions. Rename some of the files and functions in preparation for this change.
* gh-124296: Remove private dictionary version tag (PEP 699) (#124472)Sam Gross2024-10-013-41/+6
|
* gh-123961: Add a global state to _curses (#124729)Bénédikt Tran2024-09-291-2/+2
|
* gh-123497: New limit for Python integers on 64-bit platforms (GH-123724)Serhiy Storchaka2024-09-292-9/+7
| | | | | | | | | | | Instead of be limited just by the size of addressable memory (2**63 bytes), Python integers are now also limited by the number of bits, so the number of bit now always fit in a 64-bit integer. Both limits are much larger than what might be available in practice, so it doesn't affect users. _PyLong_NumBits() and _PyLong_Frexp() are now always successful.
* gh-124665: Add `_PyCodec_UnregisterError` and `_codecs._unregister_error` ↵Bénédikt Tran2024-09-291-0/+11
| | | | (#124677)
* gh-124609: Fix _Py_ThreadId for Windows builds using MinGW (#124663)Tony Roberts2024-09-272-0/+10
|