Skip to content

Commit 6b1c605

Browse files
authored
Merge branch 'main' into optimize/BINARY_SLICE
2 parents 56960c4 + 3dadc22 commit 6b1c605

File tree

92 files changed

+2148
-1320
lines changed

Some content is hidden

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

92 files changed

+2148
-1320
lines changed

.github/workflows/tail-call.yml

Lines changed: 72 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
name: Tail calling interpreter
22
on:
33
pull_request:
4-
paths:
4+
paths: &paths
55
- '.github/workflows/tail-call.yml'
66
- 'Python/bytecodes.c'
77
- 'Python/ceval.c'
88
- 'Python/ceval_macros.h'
99
- 'Python/generated_cases.c.h'
1010
push:
11-
paths:
12-
- '.github/workflows/tail-call.yml'
13-
- 'Python/bytecodes.c'
14-
- 'Python/ceval.c'
15-
- 'Python/ceval_macros.h'
16-
- 'Python/generated_cases.c.h'
11+
paths: *paths
1712
workflow_dispatch:
1813

1914
permissions:
@@ -25,117 +20,109 @@ concurrency:
2520

2621
env:
2722
FORCE_COLOR: 1
23+
LLVM_VERSION: 21
2824

2925
jobs:
30-
tail-call:
26+
windows:
3127
name: ${{ matrix.target }}
3228
runs-on: ${{ matrix.runner }}
33-
timeout-minutes: 90
29+
timeout-minutes: 60
3430
strategy:
3531
fail-fast: false
3632
matrix:
37-
target:
38-
# Un-comment as we add support for more platforms for tail-calling interpreters.
39-
# - i686-pc-windows-msvc/msvc
40-
- x86_64-pc-windows-msvc/msvc
41-
- free-threading-msvc
42-
# - aarch64-pc-windows-msvc/msvc
43-
- x86_64-apple-darwin/clang
44-
- aarch64-apple-darwin/clang
45-
- x86_64-unknown-linux-gnu/gcc
46-
- aarch64-unknown-linux-gnu/gcc
47-
- free-threading
48-
llvm:
49-
- 20
5033
include:
51-
# - target: i686-pc-windows-msvc/msvc
52-
# architecture: Win32
53-
# runner: windows-2022
5434
- target: x86_64-pc-windows-msvc/msvc
5535
architecture: x64
5636
runner: windows-2025-vs2026
57-
- target: free-threading-msvc
37+
build_flags: ""
38+
run_tests: true
39+
- target: x86_64-pc-windows-msvc/msvc-free-threading
5840
architecture: x64
5941
runner: windows-2025-vs2026
60-
# - target: aarch64-pc-windows-msvc/msvc
61-
# architecture: ARM64
62-
# runner: windows-2022
63-
- target: x86_64-apple-darwin/clang
64-
architecture: x86_64
65-
runner: macos-15-intel
66-
- target: aarch64-apple-darwin/clang
67-
architecture: aarch64
68-
runner: macos-14
69-
- target: x86_64-unknown-linux-gnu/gcc
70-
architecture: x86_64
71-
runner: ubuntu-24.04
72-
- target: aarch64-unknown-linux-gnu/gcc
73-
architecture: aarch64
74-
runner: ubuntu-24.04-arm
75-
- target: free-threading
76-
architecture: x86_64
77-
runner: ubuntu-24.04
42+
build_flags: --disable-gil
43+
run_tests: false
7844
steps:
7945
- uses: actions/checkout@v6
8046
with:
8147
persist-credentials: false
8248
- uses: actions/setup-python@v6
8349
with:
8450
python-version: '3.11'
85-
86-
- name: Native Windows MSVC (release)
87-
if: runner.os == 'Windows' && matrix.architecture != 'ARM64' && matrix.target != 'free-threading-msvc'
51+
- name: Build
8852
shell: pwsh
8953
run: |
9054
$env:PlatformToolset = "v145"
91-
./PCbuild/build.bat --tail-call-interp -c Release -p ${{ matrix.architecture }}
92-
./PCbuild/rt.bat -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
93-
94-
# No tests:
95-
- name: Native Windows MSVC with free-threading (release)
96-
if: matrix.target == 'free-threading-msvc'
97-
shell: pwsh
98-
run: |
99-
$env:PlatformToolset = "v145"
100-
./PCbuild/build.bat --tail-call-interp --disable-gil -c Release -p ${{ matrix.architecture }}
101-
102-
# No tests (yet):
103-
- name: Emulated Windows Clang (release)
104-
if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
55+
./PCbuild/build.bat --tail-call-interp ${{ matrix.build_flags }} -c Release -p ${{ matrix.architecture }}
56+
- name: Test
57+
if: matrix.run_tests
10558
shell: pwsh
10659
run: |
107-
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
108-
$env:PlatformToolset = "clangcl"
109-
$env:LLVMToolsVersion = "${{ matrix.llvm }}.1.0"
110-
$env:LLVMInstallDir = "C:\Program Files\LLVM"
111-
./PCbuild/build.bat --tail-call-interp -p ${{ matrix.architecture }}
60+
./PCbuild/rt.bat -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
11261
113-
- name: Native macOS (release)
114-
if: runner.os == 'macOS'
62+
macos:
63+
name: ${{ matrix.target }}
64+
runs-on: ${{ matrix.runner }}
65+
timeout-minutes: 60
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
include:
70+
- target: x86_64-apple-darwin/clang
71+
runner: macos-15-intel
72+
- target: aarch64-apple-darwin/clang
73+
runner: macos-14
74+
steps:
75+
- uses: actions/checkout@v6
76+
with:
77+
persist-credentials: false
78+
- uses: actions/setup-python@v6
79+
with:
80+
python-version: '3.11'
81+
- name: Install dependencies
11582
run: |
11683
brew update
117-
brew install llvm@${{ matrix.llvm }}
84+
brew install llvm@${{ env.LLVM_VERSION }}
85+
- name: Build
86+
run: |
11887
export SDKROOT="$(xcrun --show-sdk-path)"
119-
export PATH="/usr/local/opt/llvm@${{ matrix.llvm }}/bin:$PATH"
120-
export PATH="/opt/homebrew/opt/llvm@${{ matrix.llvm }}/bin:$PATH"
121-
CC=clang-20 ./configure --with-tail-call-interp
88+
export PATH="/usr/local/opt/llvm@${{ env.LLVM_VERSION }}/bin:$PATH"
89+
export PATH="/opt/homebrew/opt/llvm@${{ env.LLVM_VERSION }}/bin:$PATH"
90+
CC=clang-${{ env.LLVM_VERSION }} ./configure --with-tail-call-interp
12291
make all --jobs 4
92+
- name: Test
93+
run: |
12394
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
12495
125-
- name: Native Linux (debug)
126-
if: runner.os == 'Linux' && matrix.target != 'free-threading'
96+
linux:
97+
name: ${{ matrix.target }}
98+
runs-on: ${{ matrix.runner }}
99+
timeout-minutes: 60
100+
strategy:
101+
fail-fast: false
102+
matrix:
103+
include:
104+
- target: x86_64-unknown-linux-gnu/gcc
105+
runner: ubuntu-24.04
106+
configure_flags: --with-pydebug
107+
- target: x86_64-unknown-linux-gnu/gcc-free-threading
108+
runner: ubuntu-24.04
109+
configure_flags: --disable-gil
110+
- target: aarch64-unknown-linux-gnu/gcc
111+
runner: ubuntu-24.04-arm
112+
configure_flags: --with-pydebug
113+
steps:
114+
- uses: actions/checkout@v6
115+
with:
116+
persist-credentials: false
117+
- uses: actions/setup-python@v6
118+
with:
119+
python-version: '3.11'
120+
- name: Build
127121
run: |
128-
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
129-
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
130-
CC=clang-20 ./configure --with-tail-call-interp --with-pydebug
122+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ env.LLVM_VERSION }}
123+
export PATH="$(llvm-config-${{ env.LLVM_VERSION }} --bindir):$PATH"
124+
CC=clang-${{ env.LLVM_VERSION }} ./configure --with-tail-call-interp ${{ matrix.configure_flags }}
131125
make all --jobs 4
132-
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
133-
134-
- name: Native Linux with free-threading (release)
135-
if: matrix.target == 'free-threading'
126+
- name: Test
136127
run: |
137-
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
138-
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
139-
CC=clang-20 ./configure --with-tail-call-interp --disable-gil
140-
make all --jobs 4
141128
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3

Doc/c-api/module.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,11 @@ remove it.
725725
726726
An array of additional slots, terminated by a ``{0, NULL}`` entry.
727727
728-
This array may not contain slots corresponding to :c:type:`PyModuleDef`
729-
members.
730-
For example, you cannot use :c:macro:`Py_mod_name` in :c:member:`!m_slots`;
731-
the module name must be given as :c:member:`PyModuleDef.m_name`.
728+
If the array contains slots corresponding to :c:type:`PyModuleDef`
729+
members, the values must match.
730+
For example, if you use :c:macro:`Py_mod_name` in :c:member:`!m_slots`,
731+
:c:member:`PyModuleDef.m_name` must be set to the same pointer
732+
(not just an equal string).
732733
733734
.. versionchanged:: 3.5
734735

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ although there is currently no date scheduled for their removal.
3535
* Support for ``__complex__()`` method returning a strict subclass of
3636
:class:`complex`: these methods will be required to return an instance of
3737
:class:`complex`.
38-
* Delegation of ``int()`` to ``__trunc__()`` method.
3938
* Passing a complex number as the *real* or *imag* argument in the
4039
:func:`complex` constructor is now deprecated; it should only be passed
4140
as a single positional argument.

Doc/library/asyncio-eventloop.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,9 @@ clocks to track time.
297297
are called is undefined.
298298

299299
The optional positional *args* will be passed to the callback when
300-
it is called. If you want the callback to be called with keyword
301-
arguments use :func:`functools.partial`.
300+
it is called. Use :func:`functools.partial`
301+
:ref:`to pass keyword arguments <asyncio-pass-keywords>` to
302+
*callback*.
302303

303304
An optional keyword-only *context* argument allows specifying a
304305
custom :class:`contextvars.Context` for the *callback* to run in.
@@ -1034,8 +1035,8 @@ Watching file descriptors
10341035
.. method:: loop.add_writer(fd, callback, *args)
10351036

10361037
Start monitoring the *fd* file descriptor for write availability and
1037-
invoke *callback* with the specified arguments once *fd* is available for
1038-
writing.
1038+
invoke *callback* with the specified arguments *args* once *fd* is
1039+
available for writing.
10391040

10401041
Any preexisting callback registered for *fd* is cancelled and replaced by
10411042
*callback*.
@@ -1308,7 +1309,8 @@ Unix signals
13081309

13091310
.. method:: loop.add_signal_handler(signum, callback, *args)
13101311

1311-
Set *callback* as the handler for the *signum* signal.
1312+
Set *callback* as the handler for the *signum* signal,
1313+
passing *args* as positional arguments.
13121314

13131315
The callback will be invoked by *loop*, along with other queued callbacks
13141316
and runnable coroutines of that event loop. Unlike signal handlers
@@ -1343,7 +1345,8 @@ Executing code in thread or process pools
13431345

13441346
.. awaitablemethod:: loop.run_in_executor(executor, func, *args)
13451347

1346-
Arrange for *func* to be called in the specified executor.
1348+
Arrange for *func* to be called in the specified executor
1349+
passing *args* as positional arguments.
13471350

13481351
The *executor* argument should be an :class:`concurrent.futures.Executor`
13491352
instance. The default executor is used if *executor* is ``None``.

Doc/library/datetime.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ requires, and these work on all supported platforms.
25402540
| ``%e`` | The day of the month as a | ␣1, ␣2, ..., 31 | |
25412541
| | space-padded decimal number. | | |
25422542
+-----------+--------------------------------+------------------------+-------+
2543-
| ``%F`` | Equivalent to ``%Y-%m-%d``, | 2025-10-11, | \(0) |
2543+
| ``%F`` | Equivalent to ``%Y-%m-%d``, | 2025-10-11, | |
25442544
| | the ISO 8601 format. | 1001-12-30 | |
25452545
+-----------+--------------------------------+------------------------+-------+
25462546
| ``%g`` | Last 2 digits of ISO 8601 year | 00, 01, ..., 99 | \(0) |
@@ -2673,10 +2673,10 @@ differences between platforms in handling of unsupported format specifiers.
26732673
``%G``, ``%u`` and ``%V`` were added.
26742674

26752675
.. versionadded:: 3.12
2676-
``%:z`` was added for :meth:`~.datetime.strftime`
2676+
``%:z`` was added for :meth:`~.datetime.strftime`.
26772677

26782678
.. versionadded:: 3.15
2679-
``%:z`` was added for :meth:`~.datetime.strptime`
2679+
``%:z`` and ``%F`` were added for :meth:`~.datetime.strptime`.
26802680

26812681
Technical Detail
26822682
^^^^^^^^^^^^^^^^

Doc/library/enum.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ Utilities and Decorators
10531053
>>> enum.bin(~10) # ~10 is -11
10541054
'0b1 0101'
10551055

1056-
.. versionadded:: 3.10
1056+
.. versionadded:: 3.11
10571057

10581058
---------------
10591059

Doc/library/stdtypes.rst

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2180,7 +2180,18 @@ expression support in the :mod:`re` module).
21802180
Return ``True`` if all characters in the string are alphanumeric and there is at
21812181
least one character, ``False`` otherwise. A character ``c`` is alphanumeric if one
21822182
of the following returns ``True``: ``c.isalpha()``, ``c.isdecimal()``,
2183-
``c.isdigit()``, or ``c.isnumeric()``.
2183+
``c.isdigit()``, or ``c.isnumeric()``. For example::
2184+
2185+
.. doctest::
2186+
2187+
>>> 'abc123'.isalnum()
2188+
True
2189+
>>> 'abc123!@#'.isalnum()
2190+
False
2191+
>>> ''.isalnum()
2192+
False
2193+
>>> ' '.isalnum()
2194+
False
21842195

21852196

21862197
.. method:: str.isalpha()
@@ -2472,6 +2483,19 @@ expression support in the :mod:`re` module).
24722483
after the separator. If the separator is not found, return a 3-tuple containing
24732484
the string itself, followed by two empty strings.
24742485

2486+
For example:
2487+
2488+
.. doctest::
2489+
2490+
>>> 'Monty Python'.partition(' ')
2491+
('Monty', ' ', 'Python')
2492+
>>> "Monty Python's Flying Circus".partition(' ')
2493+
('Monty', ' ', "Python's Flying Circus")
2494+
>>> 'Monty Python'.partition('-')
2495+
('Monty Python', '', '')
2496+
2497+
See also :meth:`rpartition`.
2498+
24752499

24762500
.. method:: str.removeprefix(prefix, /)
24772501

@@ -2846,6 +2870,14 @@ expression support in the :mod:`re` module).
28462870
You can use :meth:`str.maketrans` to create a translation map from
28472871
character-to-character mappings in different formats.
28482872

2873+
The following example uses a mapping to replace ``'a'`` with ``'X'``,
2874+
``'b'`` with ``'Y'``, and delete ``'c'``:
2875+
2876+
.. doctest::
2877+
2878+
>>> 'abc123'.translate({ord('a'): 'X', ord('b'): 'Y', ord('c'): None})
2879+
'XY123'
2880+
28492881
See also the :mod:`codecs` module for a more flexible approach to custom
28502882
character mappings.
28512883

0 commit comments

Comments
 (0)