Commit graph

10410 commits

Author SHA1 Message Date
Neko Asakura
d2d24e46d3
gh-100239: expose sq_repeat helpers for BINARY_OP_EXTEND (#148791) 2026-05-08 11:12:20 +00:00
Neko Asakura
49918f5b0c
gh-149481: skip FOR_ITER inline specialization for Python __next__ (#149491)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-05-07 23:02:04 +00:00
Neil Schemenauer
13188dbf85
gh-148937: revert process RSS based GC deferral (#149475) 2026-05-07 14:32:14 +03:00
Peter Bierma
2b7c28a440
gh-149101: Implement PEP 788 (GH-149116)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
2026-05-06 17:39:30 -04:00
Alex Malyshev
646853df13
gh-145559: Add PyUnstable_DumpTraceback() and PyUnstable_DumpTracebackThreads() (#148145)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-05-06 15:01:12 +00:00
Daniele Parmeggiani
1bdfc0f253
gh-146270: Fix PyMember_SetOne(..., NULL) not being atomic (gh-148800)
Fixes a sequential consistency bug whereby two threads that are deleting a struct member may observe both their deletions to be successful.
2026-05-06 09:50:24 -04:00
Hugo van Kemenade
e7613f2735
gh-148766: Add colour to Python help (#148767) 2026-05-06 16:48:04 +03:00
Wulian233
0b75b7338d
gh-100239: specialize mixed int/float inplace binary ops (GH-149413) 2026-05-06 13:59:08 +01:00
Mark Shannon
70bd1c2dd2
GH-143732: SEND specialization (GH-148963)
* SEND specialization. Adds 2 new specialized instructions:

* SEND_VIRTUAL: for sends to virtual iterators e.g lists and tuples
* SEND_ASYNC_GEN: for sends to async generators

Tweak FOR_ITER_VIRTUAL so that SEND_VIRTUAL and FOR_ITER_VIRTUAL use equivalent guards
2026-05-05 15:19:16 +01:00
Diego Russo
1e5d94274d
GH-126910: Add GNU backtrace support for unwinding JIT frames (#149104)
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2026-05-05 09:29:07 +01:00
Petr Viktorin
508b49845d
gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2026-05-05 09:18:04 +02:00
Uxío García Andrade
2995d45659
gh-137293: Ignore Exceptions when searching ELF File in Remote Debug (#137309) 2026-05-05 01:51:39 +01:00
Pablo Galindo Salgado
9a268e3e33
gh-98894: Restore function entry/exit DTrace probes (#142397)
The function__entry and function__return probes stopped working in Python 3.11
when the interpreter was restructured around the new bytecode system. This change
restores these probes by adding DTRACE_FUNCTION_ENTRY() at the start_frame label
in bytecodes.c and DTRACE_FUNCTION_RETURN() in the RETURN_VALUE and YIELD_VALUE
instructions. The helper functions are defined in ceval.c and extract the
filename, function name, and line number from the frame before firing the probe.

This builds on the approach from https://github.com/python/cpython/pull/125019
but avoids modifying the JIT template since the JIT does not currently support
DTrace. The macros are conditionally compiled with WITH_DTRACE and are no-ops
otherwise. The tests have been updated to use modern opcode names (CALL, CALL_KW,
CALL_FUNCTION_EX) and a new bpftrace backend was added for Linux CI alongside
the existing SystemTap tests. Line probe tests were removed since that probe
was never restored after 3.11.
2026-05-05 00:29:55 +00:00
Sergey Miryanov
e89568f0cb
GH-148726: Add heap_size to generational GC (#149195) 2026-05-04 22:14:45 +01:00
Steve Dower
10f950c9bb
gh-148690: Build Windows freethreaded binaries into separate directory and include python3t.dll on GIL-enabled (GH-149218)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-05-04 17:45:08 +01:00
Neko Asakura
9846407eaf
gh-143732: add specialization for FOR_ITER (GH-148745) 2026-05-04 17:29:10 +01:00
Victor Stinner
952784af47
gh-137030: Fix YIELD_VALUE bytecode assertion (#149184)
Co-authored-by: Mark Shannon <mark@hotpy.org>
2026-05-04 18:09:57 +02:00
Maurycy Pawłowski-Wieroński
72f29dc704
gh-147998: Fix possible memory leak in _pop_preserved (crossinterp.c) (GH-147999) 2026-05-04 16:45:31 +03:00
Wulian233
c3972f2795
gh-148418: Fix a possible reference leak in a corrupted TYPE_CODE marshal stream (GH-148419) 2026-05-04 16:42:02 +03:00
Kumar Aditya
5847931d11
gh-143732: allow dict subclasses to be specialized (GH-148128) 2026-05-04 09:39:03 +01:00
sobolevn
726a17e265
gh-149243: Check for recursion limits in CALL_ALLOC_AND_ENTER_INIT (#149310) 2026-05-03 13:26:05 +03:00
Wulian233
8a7eddaa84
gh-149217: Avoid adding dependencies on immutable, immortal classes in the JIT (GH149256) 2026-05-03 11:06:39 +01:00
Serhiy Storchaka
00c4a946f4
gh-143231: Add the module attribute to warnings.WarningMessage (GH-149298) 2026-05-03 09:35:47 +00:00
Neko Asakura
7c9ad27dd1
gh-148871: extend and improve LOAD_COMMON_CONSTANT (GH-148971) 2026-05-02 19:59:51 +01:00
Brian Schubert
bdedc4a20e
gh-116021: Deprecate support for instantiating abstract AST nodes (#137865)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-05-02 09:50:06 -07:00
sobolevn
98afa03522
gh-149282: Fix gc.c compilation with --enable-pystats (#149283) 2026-05-02 18:24:17 +03:00
Sergey Miryanov
39f123c587
GH-146527: Add get_gc_stats function to _remote_debugging (#148071) 2026-05-02 15:04:18 +00:00
Neko Asakura
2ca6333065
gh-148380: remove all uses of _PyType_LookupByVersion in optimizer_bytecodes.c (GH-148394) 2026-05-02 15:45:38 +01:00
Diego Russo
c7b7ca2cd5
GH-126910: Add gdb support for unwinding JIT frames (#146071)
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2026-05-02 13:42:03 +00:00
Neko Asakura
0102c1d9b9
gh-149204: add _RROT_3 uop to reduce stack moves (GH-149205) 2026-05-01 12:35:31 +01:00
Sergey Miryanov
1575a81bf2
GH-148726: Forward-port generational GC. (GH-148746)
The replaces the incremental GC with a forward port (from 3.13) of the generational GC.

Co-Authored-By: Neil Schemenauer <nas@arctrix.com>
Co-Authored-By: Zanie Blue <contact@zanie.dev>
Co-Authored-By: Sergey Miryanov <sergey.miryanov@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-04-30 12:19:13 -07:00
Eric Froemling
7686abe063
gh-149085: Add max_threads keyword to faulthandler.dump_traceback() (GH-149106)
Add a keyword-only `max_threads` argument to `dump_traceback()` and
`dump_traceback_later()`, defaulting to 100 to preserve existing
behavior. Allows server processes with many worker threads to dump
beyond the historical 100-thread cap (previously a hardcoded
`MAX_NTHREADS = 100` in `Python/traceback.c`).

The cap matters in practice: tstates are prepended to the
PyInterpreterState linked list, so the dump walks newest-first. With
more than 100 threads alive, the main thread (oldest, at the tail) is
silently elided from watchdog dumps -- exactly the thread that's
usually wanted.

The hardcoded value is moved to a new internal macro
`_Py_TRACEBACK_MAX_NTHREADS` in `pycore_traceback.h` so the in-tree
fatal-signal callers all reference one source of truth.
2026-04-30 09:27:57 -04:00
Petr Viktorin
4599335a83
gh-149122: Fix refleak in codegen (GH-149179) 2026-04-30 10:05:48 +00:00
Pieter Eendebak
7fe51ceae8
gh-149049: Fix jit binary op stack underflow (GH-149076) 2026-04-30 10:36:04 +01:00
Irit Katriel
16f292ef4e
gh-149122: Fix segfault in compiler when certain builtin functions are passed a coroutine as arg (#149138) 2026-04-29 13:35:51 +00:00
Neko Asakura
2b6a13710f
gh-148211: decompose _SHUFFLE_3_LOAD_CONST_INLINE_BORROW in JIT (GH-148816) 2026-04-28 13:48:23 +01:00
Hai Zhu
be968c7210
gh-148571: [JIT] Preserve family-head recorder layouts for specialized opcode families (GH-148730)
* Records the same objects for each member of family before execution
* Records derived values when recording the trace
* This makes sure that specialization, or deoptimization, does not cause invalid values to be recorded
2026-04-28 13:41:16 +01:00
Brian Schubert
d2f506ae07
gh-137600: Promote ast node constructor deprecation warnings to errors (#137601)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-04-28 02:51:06 +00:00
Jelle Zijlstra
29a92abb60
gh-148829: Implement PEP 661 (#148831)
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-04-27 19:28:30 -07:00
Mark Shannon
276f474c9a
GH-146073: Add fitness to executor dumps. (GH-148959) 2026-04-27 17:34:09 +01:00
Anonymous941
54a8921140
Fix typo in ceval.c error message (#148860)
Fix the "multiple values for keyword argument" error message
used when the function's `__qualname__` cannot be retrieved.
2026-04-27 09:21:53 +02:00
zSirius
5d416324c5
gh-146455: Fix O(N²) in add_const() after constant folding moved to CFG (#146456)
The add_const() function in flowgraph.c uses a linear search over the
consts list to find the index of a constant. After gh-126835 moved
constant folding from the AST optimizer to the CFG optimizer, this
function is now called N times for N inner tuple elements during
fold_tuple_of_constants(), resulting in O(N²) total time.

Fix by maintaining an auxiliary _Py_hashtable_t that maps object
pointers to their indices in the consts list, providing O(1) lookup.

For a file with 100,000 constant 2-tuples:
- Before: 10.38s (add_const occupies 83.76% of CPU time)
- After:  1.48s
2026-04-26 15:15:24 +03:00
Irit Katriel
c650b51c32
gh-148973: fix segfault on mismatch between consts size and oparg in compiler (#148974) 2026-04-25 10:47:41 +01:00
Gregory P. Smith
665b7dfcfa
Improve hash() builtin docstring with caveats. (GH-125229)
Improve  `hash()` builtin docstring with caveats.

Mention its return type and that the value can be expected to change between
processes (hash randomization).

Why? The `hash` builtin gets reached for and used by a lot of people whether it
is the right tool or not. IDEs surface docstrings and people use pydoc and
`help(hash)`.
2026-04-24 16:36:46 +00:00
Hai Zhu
618b726d68
gh-146073: Add fitness/exit quality mechanism for JIT trace frontend (GH-148089)
* Replaces ad-hoc logic for ending traces with a simple inequality: `fitness < exit_quality`
* Fitness starts high and is reduced for branches, backward edges, calls and trace length
* Exit quality reflect how good a spot that instruction is to end a trace. Closing a loop is very, specializable instructions are very low and the others in between.
2026-04-24 10:37:01 +01:00
Diego Russo
9633c5239d
GH-126910: Build/link the JIT shim in the Python interpreter (#148872) 2026-04-23 12:23:18 +01:00
Sam Gross
ad3c5b7958
gh-148820: Fix _PyRawMutex use-after-free on spurious semaphore wakeup (gh-148852)
_PyRawMutex_UnlockSlow CAS-removes the waiter from the list and then
calls _PySemaphore_Wakeup, with no handshake. If _PySemaphore_Wait
returns Py_PARK_INTR, the waiter can destroy its stack-allocated
semaphore before the unlocker's Wakeup runs, causing a fatal error from
ReleaseSemaphore / sem_post.

Loop in _PyRawMutex_LockSlow until _PySemaphore_Wait returns Py_PARK_OK,
which is only signalled when a matching Wakeup has been observed.

Also include GetLastError() and the handle in the Windows fatal messages
in _PySemaphore_Init, _PySemaphore_Wait, and _PySemaphore_Wakeup to make
similar races easier to diagnose in the future.
2026-04-22 14:31:19 -04:00
Gabriele N. Tornetta
858e69eab0
gh-142186: Allow all PEP-669 events to be per-code object and disableable (GH-146182)
* Make the `PY_UNWIND` monitoring event available as a code-local
event to allow trapping on function exit events when an exception
bubbles up. This complements the PY_RETURN event by allowing to
catch any function exit event.

* Allow `PY_UNWIND`  to be `DISABLE`d; disabling it disables the event for the whole code object.

* Do the above for `PY_THROW`, `RAISE`, `EXCEPTION_HANDLED`, and `RERAISE` events.
2026-04-22 09:08:23 +01:00
AraHaan
789120e826
gh-148790: Eliminate redundant call to _PyRuntime_Initialize in Py_InitializeEx (GH-121628) 2026-04-20 10:01:06 -04:00
Dino Viehland
d81599eeb7
gh-148659: Export a few more functions required for external JITs (#148704)
Export a few more functions required for external JITs
2026-04-18 11:32:22 -07:00