Skip to content

Commit 41961ed

Browse files
authored
Merge branch 'main' into fix-PyLong_FromString/143050
2 parents 1f363f4 + 70d1b08 commit 41961ed

File tree

111 files changed

+4497
-1863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+4497
-1863
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,21 @@ jobs:
165165
free-threading:
166166
- false
167167
- true
168+
interpreter:
169+
- switch-case
168170
exclude:
169171
# Skip Win32 on free-threaded builds
170172
- { arch: Win32, free-threading: true }
173+
include:
174+
# msvc::musttail is currently only supported on x64,
175+
# and only supported on 3.15+.
176+
- { arch: x64, free-threading: false, interpreter: tail-call }
177+
- { arch: x64, free-threading: true, interpreter: tail-call }
171178
uses: ./.github/workflows/reusable-windows.yml
172179
with:
173180
arch: ${{ matrix.arch }}
174181
free-threading: ${{ matrix.free-threading }}
182+
interpreter: ${{ matrix.interpreter }}
175183

176184
build-windows-msi:
177185
# ${{ '' } is a hack to nest jobs under the same sidebar category.

.github/workflows/reusable-emscripten.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
build-emscripten-reusable:
1111
name: 'build and test'
1212
runs-on: ubuntu-24.04
13-
timeout-minutes: 60
13+
timeout-minutes: 40
1414
steps:
1515
- uses: actions/checkout@v6
1616
with:

.github/workflows/reusable-windows.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
required: false
1313
type: boolean
1414
default: false
15+
interpreter:
16+
description: Which interpreter to build (switch-case or tail-call)
17+
required: true
18+
type: string
1519

1620
env:
1721
FORCE_COLOR: 1
@@ -20,7 +24,7 @@ env:
2024
2125
jobs:
2226
build:
23-
name: Build and test (${{ inputs.arch }})
27+
name: Build and test (${{ inputs.arch }}, ${{ inputs.interpreter }})
2428
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2025-vs2026' }}
2529
timeout-minutes: 60
2630
env:
@@ -33,9 +37,12 @@ jobs:
3337
if: inputs.arch != 'Win32'
3438
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
3539
- name: Build CPython
40+
# msvc::musttail is not supported for debug builds, so we have to
41+
# switch to release.
3642
run: >-
3743
.\\PCbuild\\build.bat
38-
-e -d -v
44+
-e -v
45+
${{ inputs.interpreter == 'switch-case' && '-d' || '--tail-call-interp -c Release' }}
3946
-p "${ARCH}"
4047
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
4148
shell: bash
@@ -45,6 +52,7 @@ jobs:
4552
run: >-
4653
.\\PCbuild\\rt.bat
4754
-p "${ARCH}"
48-
-d -q --fast-ci
55+
-q --fast-ci
56+
${{ inputs.interpreter == 'switch-case' && '-d' || '' }}
4957
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
5058
shell: bash

.github/workflows/tail-call.yml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,6 @@ env:
2323
LLVM_VERSION: 21
2424

2525
jobs:
26-
windows:
27-
name: ${{ matrix.target }}
28-
runs-on: ${{ matrix.runner }}
29-
timeout-minutes: 60
30-
strategy:
31-
fail-fast: false
32-
matrix:
33-
include:
34-
- target: x86_64-pc-windows-msvc/msvc
35-
architecture: x64
36-
runner: windows-2025-vs2026
37-
build_flags: ""
38-
run_tests: true
39-
- target: x86_64-pc-windows-msvc/msvc-free-threading
40-
architecture: x64
41-
runner: windows-2025-vs2026
42-
build_flags: --disable-gil
43-
run_tests: false
44-
steps:
45-
- uses: actions/checkout@v6
46-
with:
47-
persist-credentials: false
48-
- uses: actions/setup-python@v6
49-
with:
50-
python-version: '3.11'
51-
- name: Build
52-
shell: pwsh
53-
run: |
54-
./PCbuild/build.bat --tail-call-interp ${{ matrix.build_flags }} -c Release -p ${{ matrix.architecture }}
55-
- name: Test
56-
if: matrix.run_tests
57-
shell: pwsh
58-
run: |
59-
./PCbuild/rt.bat -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
60-
6126
macos:
6227
name: ${{ matrix.target }}
6328
runs-on: ${{ matrix.runner }}

Doc/library/array.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ defined:
4242
+-----------+--------------------+-------------------+-----------------------+-------+
4343
| ``'Q'`` | unsigned long long | int | 8 | |
4444
+-----------+--------------------+-------------------+-----------------------+-------+
45+
| ``'e'`` | _Float16 | float | 2 | \(3) |
46+
+-----------+--------------------+-------------------+-----------------------+-------+
4547
| ``'f'`` | float | float | 4 | |
4648
+-----------+--------------------+-------------------+-----------------------+-------+
4749
| ``'d'`` | double | float | 8 | |
4850
+-----------+--------------------+-------------------+-----------------------+-------+
49-
| ``'F'`` | float complex | complex | 8 | \(3) |
51+
| ``'F'`` | float complex | complex | 8 | \(4) |
5052
+-----------+--------------------+-------------------+-----------------------+-------+
51-
| ``'D'`` | double complex | complex | 16 | \(3) |
53+
| ``'D'`` | double complex | complex | 16 | \(4) |
5254
+-----------+--------------------+-------------------+-----------------------+-------+
5355

5456

@@ -69,6 +71,15 @@ Notes:
6971
.. versionadded:: 3.13
7072

7173
(3)
74+
The IEEE 754 binary16 "half precision" type was introduced in the 2008
75+
revision of the `IEEE 754 standard <ieee 754 standard_>`_.
76+
This type is not widely supported by C compilers. It's available
77+
as :c:expr:`_Float16` type, if the compiler supports the Annex H
78+
of the C23 standard.
79+
80+
.. versionadded:: next
81+
82+
(4)
7283
Complex types (``F`` and ``D``) are available unconditionally,
7384
regardless on support for complex types (the Annex G of the C11 standard)
7485
by the C compiler.
@@ -304,3 +315,5 @@ Examples::
304315

305316
`NumPy <https://numpy.org/>`_
306317
The NumPy package defines another array type.
318+
319+
.. _ieee 754 standard: https://en.wikipedia.org/wiki/IEEE_754-2008_revision

Doc/library/getpass.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,27 @@ The :mod:`!getpass` module provides two functions:
3939
On Unix systems, when *echo_char* is set, the terminal will be
4040
configured to operate in
4141
:manpage:`noncanonical mode <termios(3)#Canonical_and_noncanonical_mode>`.
42-
In particular, this means that line editing shortcuts such as
43-
:kbd:`Ctrl+U` will not work and may insert unexpected characters into
44-
the input.
42+
Common terminal control characters are supported:
43+
44+
* :kbd:`Ctrl+A` - Move cursor to beginning of line
45+
* :kbd:`Ctrl+E` - Move cursor to end of line
46+
* :kbd:`Ctrl+K` - Kill (delete) from cursor to end of line
47+
* :kbd:`Ctrl+U` - Kill (delete) entire line
48+
* :kbd:`Ctrl+W` - Erase previous word
49+
* :kbd:`Ctrl+V` - Insert next character literally (quote)
50+
* :kbd:`Backspace`/:kbd:`DEL` - Delete character before cursor
51+
52+
These shortcuts work by reading the terminal's configured control
53+
character mappings from termios settings.
4554

4655
.. versionchanged:: 3.14
4756
Added the *echo_char* parameter for keyboard feedback.
4857

58+
.. versionchanged:: next
59+
When using non-empty *echo_char* on Unix, keyboard shortcuts (including
60+
cursor movement and line editing) are now properly handled using the
61+
terminal's control character configuration.
62+
4963
.. exception:: GetPassWarning
5064

5165
A :exc:`UserWarning` subclass issued when password input may be echoed.

Doc/library/profiling.sampling.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,47 @@ at the top indicate functions that consume significant time either directly
10031003
or through their callees.
10041004

10051005

1006+
Differential flame graphs
1007+
~~~~~~~~~~~~~~~~~~~~~~~~~
1008+
1009+
Differential flame graphs compare two profiling runs to highlight where
1010+
performance changed. This helps identify regressions introduced by code changes
1011+
and validate that optimizations achieved their intended effect::
1012+
1013+
# Capture baseline profile
1014+
python -m profiling.sampling run --binary -o baseline.bin script.py
1015+
1016+
# After modifying code, generate differential flamegraph
1017+
python -m profiling.sampling run --diff-flamegraph baseline.bin -o diff.html script.py
1018+
1019+
The visualization draws the current profile with frame widths showing current
1020+
time consumption, then applies color to indicate how each function changed
1021+
relative to the baseline.
1022+
1023+
**Color coding**:
1024+
1025+
- **Red**: Functions consuming more time (regressions). Lighter shades indicate
1026+
modest increases, while darker shades show severe regressions.
1027+
1028+
- **Blue**: Functions consuming less time (improvements). Lighter shades for
1029+
modest reductions, darker shades for significant speedups.
1030+
1031+
- **Gray**: Minimal or no change.
1032+
1033+
- **Purple**: New functions not present in the baseline.
1034+
1035+
Frame colors indicate changes in **direct time** (time when the function was at
1036+
the top of the stack, actively executing), not cumulative time including callees.
1037+
Hovering over a frame shows comparison details including baseline time, current
1038+
time, and the percentage change.
1039+
1040+
Some call paths may disappear entirely between profiles. These are called
1041+
**elided stacks** and occur when optimizations eliminate code paths or certain
1042+
branches stop executing. If elided stacks are present, an elided toggle appears
1043+
allowing you to switch between the main differential view and an elided-only
1044+
view that shows just the removed paths (colored purple).
1045+
1046+
10061047
Gecko format
10071048
------------
10081049

@@ -1488,6 +1529,10 @@ Output options
14881529

14891530
Generate self-contained HTML flame graph.
14901531

1532+
.. option:: --diff-flamegraph <baseline.bin>
1533+
1534+
Generate differential flamegraph comparing to a baseline binary profile.
1535+
14911536
.. option:: --gecko
14921537

14931538
Generate Gecko JSON format for Firefox Profiler.

Doc/library/select.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The module defines the following:
6262

6363
*sizehint* informs epoll about the expected number of events to be
6464
registered. It must be positive, or ``-1`` to use the default. It is only
65-
used on older systems where :c:func:`!epoll_create1` is not available;
65+
used on older systems where :manpage:`epoll_create1(2)` is not available;
6666
otherwise it has no effect (though its value is still checked).
6767

6868
*flags* is deprecated and completely ignored. However, when supplied, its
@@ -89,6 +89,11 @@ The module defines the following:
8989
The *flags* parameter. ``select.EPOLL_CLOEXEC`` is used by default now.
9090
Use :func:`os.set_inheritable` to make the file descriptor inheritable.
9191

92+
.. versionchanged:: next
93+
94+
When CPython is built, this function may be disabled using
95+
:option:`--disable-epoll`.
96+
9297

9398
.. function:: poll()
9499

Doc/library/socket.rst

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ is implicit on send operations.
3939
A TLS/SSL wrapper for socket objects.
4040

4141

42+
.. _socket-addresses:
43+
4244
Socket families
4345
---------------
4446

@@ -903,7 +905,7 @@ The following functions all create :ref:`socket objects <socket-objects>`.
903905

904906
Build a pair of connected socket objects using the given address family, socket
905907
type, and protocol number. Address family, socket type, and protocol number are
906-
as for the :func:`~socket.socket` function above. The default family is :const:`AF_UNIX`
908+
as for the :func:`~socket.socket` function. The default family is :const:`AF_UNIX`
907909
if defined on the platform; otherwise, the default is :const:`AF_INET`.
908910

909911
The newly created sockets are :ref:`non-inheritable <fd_inheritance>`.
@@ -999,8 +1001,8 @@ The following functions all create :ref:`socket objects <socket-objects>`.
9991001

10001002
Duplicate the file descriptor *fd* (an integer as returned by a file object's
10011003
:meth:`~io.IOBase.fileno` method) and build a socket object from the result. Address
1002-
family, socket type and protocol number are as for the :func:`~socket.socket` function
1003-
above. The file descriptor should refer to a socket, but this is not checked ---
1004+
family, socket type and protocol number are as for the :func:`~socket.socket` function.
1005+
The file descriptor should refer to a socket, but this is not checked ---
10041006
subsequent operations on the object may fail if the file descriptor is invalid.
10051007
This function is rarely needed, but can be used to get or set socket options on
10061008
a socket passed to a program as standard input or output (such as a server
@@ -1564,8 +1566,8 @@ to sockets.
15641566

15651567
.. method:: socket.bind(address)
15661568

1567-
Bind the socket to *address*. The socket must not already be bound. (The format
1568-
of *address* depends on the address family --- see above.)
1569+
Bind the socket to *address*. The socket must not already be bound. The format
1570+
of *address* depends on the address family --- see :ref:`socket-addresses`.
15691571

15701572
.. audit-event:: socket.bind self,address socket.socket.bind
15711573

@@ -1598,8 +1600,8 @@ to sockets.
15981600

15991601
.. method:: socket.connect(address)
16001602

1601-
Connect to a remote socket at *address*. (The format of *address* depends on the
1602-
address family --- see above.)
1603+
Connect to a remote socket at *address*. The format of *address* depends on the
1604+
address family --- see :ref:`socket-addresses`.
16031605

16041606
If the connection is interrupted by a signal, the method waits until the
16051607
connection completes, or raises a :exc:`TimeoutError` on timeout, if the
@@ -1674,16 +1676,16 @@ to sockets.
16741676
.. method:: socket.getpeername()
16751677

16761678
Return the remote address to which the socket is connected. This is useful to
1677-
find out the port number of a remote IPv4/v6 socket, for instance. (The format
1678-
of the address returned depends on the address family --- see above.) On some
1679-
systems this function is not supported.
1679+
find out the port number of a remote IPv4/v6 socket, for instance. The format
1680+
of the address returned depends on the address family --- see :ref:`socket-addresses`.
1681+
On some systems this function is not supported.
16801682

16811683

16821684
.. method:: socket.getsockname()
16831685

16841686
Return the socket's own address. This is useful to find out the port number of
1685-
an IPv4/v6 socket, for instance. (The format of the address returned depends on
1686-
the address family --- see above.)
1687+
an IPv4/v6 socket, for instance. The format of the address returned depends on
1688+
the address family --- see :ref:`socket-addresses`.
16871689

16881690

16891691
.. method:: socket.getsockopt(level, optname[, buflen])
@@ -1795,7 +1797,8 @@ to sockets.
17951797
where *bytes* is a bytes object representing the data received and *address* is the
17961798
address of the socket sending the data. See the Unix manual page
17971799
:manpage:`recv(2)` for the meaning of the optional argument *flags*; it defaults
1798-
to zero. (The format of *address* depends on the address family --- see above.)
1800+
to zero. The format of *address* depends on the address family --- see
1801+
:ref:`socket-addresses`.
17991802

18001803
.. versionchanged:: 3.5
18011804
If the system call is interrupted and the signal handler does not raise
@@ -1925,8 +1928,8 @@ to sockets.
19251928
new bytestring. The return value is a pair ``(nbytes, address)`` where *nbytes* is
19261929
the number of bytes received and *address* is the address of the socket sending
19271930
the data. See the Unix manual page :manpage:`recv(2)` for the meaning of the
1928-
optional argument *flags*; it defaults to zero. (The format of *address*
1929-
depends on the address family --- see above.)
1931+
optional argument *flags*; it defaults to zero. The format of *address*
1932+
depends on the address family --- see :ref:`socket-addresses`.
19301933

19311934

19321935
.. method:: socket.recv_into(buffer[, nbytes[, flags]])
@@ -1941,7 +1944,7 @@ to sockets.
19411944
.. method:: socket.send(bytes[, flags])
19421945

19431946
Send data to the socket. The socket must be connected to a remote socket. The
1944-
optional *flags* argument has the same meaning as for :meth:`recv` above.
1947+
optional *flags* argument has the same meaning as for :meth:`recv`.
19451948
Returns the number of bytes sent. Applications are responsible for checking that
19461949
all data has been sent; if only some of the data was transmitted, the
19471950
application needs to attempt delivery of the remaining data. For further
@@ -1956,7 +1959,7 @@ to sockets.
19561959
.. method:: socket.sendall(bytes[, flags])
19571960

19581961
Send data to the socket. The socket must be connected to a remote socket. The
1959-
optional *flags* argument has the same meaning as for :meth:`recv` above.
1962+
optional *flags* argument has the same meaning as for :meth:`recv`.
19601963
Unlike :meth:`send`, this method continues to send data from *bytes* until
19611964
either all data has been sent or an error occurs. ``None`` is returned on
19621965
success. On error, an exception is raised, and there is no way to determine how
@@ -1977,9 +1980,9 @@ to sockets.
19771980

19781981
Send data to the socket. The socket should not be connected to a remote socket,
19791982
since the destination socket is specified by *address*. The optional *flags*
1980-
argument has the same meaning as for :meth:`recv` above. Return the number of
1981-
bytes sent. (The format of *address* depends on the address family --- see
1982-
above.)
1983+
argument has the same meaning as for :meth:`recv`. Return the number of
1984+
bytes sent. The format of *address* depends on the address family --- see
1985+
:ref:`socket-addresses`.
19831986

19841987
.. audit-event:: socket.sendto self,address socket.socket.sendto
19851988

0 commit comments

Comments
 (0)