Skip to content

Commit 66e9735

Browse files
authored
Merge branch 'main' into perf/import/remove-typing-118761
2 parents 6d0b6e0 + d3adf02 commit 66e9735

File tree

111 files changed

+3152
-1382
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

+3152
-1382
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,14 @@ jobs:
231231
name: >-
232232
Ubuntu
233233
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
234+
${{ fromJSON(matrix.bolt) && '(bolt)' || '' }}
234235
needs: check_source
235236
if: needs.check_source.outputs.run_tests == 'true'
236237
strategy:
237238
matrix:
239+
bolt:
240+
- false
241+
- true
238242
free-threading:
239243
- false
240244
- true
@@ -246,9 +250,16 @@ jobs:
246250
exclude:
247251
- os: ubuntu-24.04-aarch64
248252
is-fork: true
253+
# Do not test BOLT with free-threading, to conserve resources
254+
- bolt: true
255+
free-threading: true
256+
# BOLT currently crashes during instrumentation on aarch64
257+
- os: ubuntu-24.04-aarch64
258+
bolt: true
249259
uses: ./.github/workflows/reusable-ubuntu.yml
250260
with:
251261
config_hash: ${{ needs.check_source.outputs.config_hash }}
262+
bolt-optimizations: ${{ matrix.bolt }}
252263
free-threading: ${{ matrix.free-threading }}
253264
os: ${{ matrix.os }}
254265

.github/workflows/reusable-ubuntu.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
config_hash:
77
required: true
88
type: string
9+
bolt-optimizations:
10+
description: Whether to enable BOLT optimizations
11+
required: false
12+
type: boolean
13+
default: false
914
free-threading:
1015
description: Whether to use free-threaded mode
1116
required: false
@@ -34,6 +39,12 @@ jobs:
3439
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
3540
- name: Install dependencies
3641
run: sudo ./.github/workflows/posix-deps-apt.sh
42+
- name: Install Clang and BOLT
43+
if: ${{ fromJSON(inputs.bolt-optimizations) }}
44+
run: |
45+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh 19
46+
sudo apt-get install bolt-19
47+
echo PATH="$(llvm-config-19 --bindir):$PATH" >> $GITHUB_ENV
3748
- name: Configure OpenSSL env vars
3849
run: |
3950
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV"
@@ -73,14 +84,18 @@ jobs:
7384
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
7485
- name: Configure CPython out-of-tree
7586
working-directory: ${{ env.CPYTHON_BUILDDIR }}
87+
# `test_unpickle_module_race` writes to the source directory, which is
88+
# read-only during builds — so we exclude it from profiling with BOLT.
7689
run: >-
90+
PROFILE_TASK='-m test --pgo --ignore test_unpickle_module_race'
7791
../cpython-ro-srcdir/configure
7892
--config-cache
7993
--with-pydebug
8094
--enable-slower-safety
8195
--enable-safety
8296
--with-openssl="$OPENSSL_DIR"
8397
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
98+
${{ fromJSON(inputs.bolt-optimizations) && '--enable-bolt' || '' }}
8499
- name: Build CPython out-of-tree
85100
if: ${{ inputs.free-threading }}
86101
working-directory: ${{ env.CPYTHON_BUILDDIR }}

Doc/glossary.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Glossary
115115
:keyword:`yield` expression.
116116

117117
Each :keyword:`yield` temporarily suspends processing, remembering the
118-
location execution state (including local variables and pending
118+
execution state (including local variables and pending
119119
try-statements). When the *asynchronous generator iterator* effectively
120120
resumes with another awaitable returned by :meth:`~object.__anext__`, it
121121
picks up where it left off. See :pep:`492` and :pep:`525`.
@@ -564,7 +564,7 @@ Glossary
564564
An object created by a :term:`generator` function.
565565

566566
Each :keyword:`yield` temporarily suspends processing, remembering the
567-
location execution state (including local variables and pending
567+
execution state (including local variables and pending
568568
try-statements). When the *generator iterator* resumes, it picks up where
569569
it left off (in contrast to functions which start fresh on every
570570
invocation).

Doc/library/importlib.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,15 @@ ABC hierarchy::
380380

381381
.. class:: ResourceLoader
382382

383+
*Superseded by TraversableResources*
384+
383385
An abstract base class for a :term:`loader` which implements the optional
384386
:pep:`302` protocol for loading arbitrary resources from the storage
385387
back-end.
386388

387389
.. deprecated:: 3.7
388390
This ABC is deprecated in favour of supporting resource loading
389-
through :class:`importlib.resources.abc.ResourceReader`.
391+
through :class:`importlib.resources.abc.TraversableResources`.
390392

391393
.. abstractmethod:: get_data(path)
392394

Doc/library/sys.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
This module provides access to some variables used or maintained by the
1010
interpreter and to functions that interact strongly with the interpreter. It is
11-
always available.
11+
always available. Unless explicitly noted otherwise, all variables are read-only.
1212

1313

1414
.. data:: abiflags

Doc/library/turtle.rst

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,31 @@ useful when working with learners for whom typing is not a skill.
213213
use turtle graphics with a learner.
214214

215215

216+
Automatically begin and end filling
217+
-----------------------------------
218+
219+
Starting with Python 3.14, you can use the :func:`fill` :term:`context manager`
220+
instead of :func:`begin_fill` and :func:`end_fill` to automatically begin and
221+
end fill. Here is an example::
222+
223+
with fill():
224+
for i in range(4):
225+
forward(100)
226+
right(90)
227+
228+
forward(200)
229+
230+
The code above is equivalent to::
231+
232+
begin_fill()
233+
for i in range(4):
234+
forward(100)
235+
right(90)
236+
end_fill()
237+
238+
forward(200)
239+
240+
216241
Use the ``turtle`` module namespace
217242
-----------------------------------
218243

@@ -351,6 +376,7 @@ Pen control
351376
352377
Filling
353378
| :func:`filling`
379+
| :func:`fill`
354380
| :func:`begin_fill`
355381
| :func:`end_fill`
356382
@@ -381,6 +407,7 @@ Using events
381407
| :func:`ondrag`
382408
383409
Special Turtle methods
410+
| :func:`poly`
384411
| :func:`begin_poly`
385412
| :func:`end_poly`
386413
| :func:`get_poly`
@@ -403,6 +430,7 @@ Window control
403430
| :func:`setworldcoordinates`
404431
405432
Animation control
433+
| :func:`no_animation`
406434
| :func:`delay`
407435
| :func:`tracer`
408436
| :func:`update`
@@ -1275,6 +1303,29 @@ Filling
12751303
... else:
12761304
... turtle.pensize(3)
12771305

1306+
.. function:: fill()
1307+
1308+
Fill the shape drawn in the ``with turtle.fill():`` block.
1309+
1310+
.. doctest::
1311+
:skipif: _tkinter is None
1312+
1313+
>>> turtle.color("black", "red")
1314+
>>> with turtle.fill():
1315+
... turtle.circle(80)
1316+
1317+
Using :func:`!fill` is equivalent to adding the :func:`begin_fill` before the
1318+
fill-block and :func:`end_fill` after the fill-block:
1319+
1320+
.. doctest::
1321+
:skipif: _tkinter is None
1322+
1323+
>>> turtle.color("black", "red")
1324+
>>> turtle.begin_fill()
1325+
>>> turtle.circle(80)
1326+
>>> turtle.end_fill()
1327+
1328+
.. versionadded:: next
12781329

12791330

12801331
.. function:: begin_fill()
@@ -1648,6 +1699,23 @@ Using events
16481699
Special Turtle methods
16491700
----------------------
16501701

1702+
1703+
.. function:: poly()
1704+
1705+
Record the vertices of a polygon drawn in the ``with turtle.poly():`` block.
1706+
The first and last vertices will be connected.
1707+
1708+
.. doctest::
1709+
:skipif: _tkinter is None
1710+
1711+
>>> with turtle.poly():
1712+
... turtle.forward(100)
1713+
... turtle.right(60)
1714+
... turtle.forward(100)
1715+
1716+
.. versionadded:: next
1717+
1718+
16511719
.. function:: begin_poly()
16521720

16531721
Start recording the vertices of a polygon. Current turtle position is first
@@ -1926,6 +1994,23 @@ Window control
19261994
Animation control
19271995
-----------------
19281996

1997+
.. function:: no_animation()
1998+
1999+
Temporarily disable turtle animation. The code written inside the
2000+
``no_animation`` block will not be animated;
2001+
once the code block is exited, the drawing will appear.
2002+
2003+
.. doctest::
2004+
:skipif: _tkinter is None
2005+
2006+
>>> with screen.no_animation():
2007+
... for dist in range(2, 400, 2):
2008+
... fd(dist)
2009+
... rt(90)
2010+
2011+
.. versionadded:: next
2012+
2013+
19292014
.. function:: delay(delay=None)
19302015

19312016
:param delay: positive integer

Doc/whatsnew/3.14.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,14 @@ tkinter
660660
(Contributed by Zhikang Yan in :gh:`126899`.)
661661

662662

663+
turtle
664+
------
665+
666+
* Add context managers for :func:`turtle.fill`, :func:`turtle.poly`
667+
and :func:`turtle.no_animation`.
668+
(Contributed by Marie Roald and Yngve Mardal Moe in :gh:`126350`.)
669+
670+
663671
unicodedata
664672
-----------
665673

Include/cpython/object.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,6 @@ partially-deallocated object. To check this, the tp_dealloc function must be
475475
passed as second argument to Py_TRASHCAN_BEGIN().
476476
*/
477477

478-
/* Python 3.9 private API, invoked by the macros below. */
479-
PyAPI_FUNC(int) _PyTrash_begin(PyThreadState *tstate, PyObject *op);
480-
PyAPI_FUNC(void) _PyTrash_end(PyThreadState *tstate);
481478

482479
PyAPI_FUNC(void) _PyTrash_thread_deposit_object(PyThreadState *tstate, PyObject *op);
483480
PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(PyThreadState *tstate);

Include/internal/pycore_code.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ typedef struct {
100100

101101
typedef struct {
102102
_Py_BackoffCounter counter;
103+
uint16_t external_cache[4];
103104
} _PyBinaryOpCache;
104105

105106
#define INLINE_CACHE_ENTRIES_BINARY_OP CACHE_ENTRIES(_PyBinaryOpCache)
@@ -438,7 +439,7 @@ write_u64(uint16_t *p, uint64_t val)
438439
}
439440

440441
static inline void
441-
write_obj(uint16_t *p, PyObject *val)
442+
write_ptr(uint16_t *p, void *val)
442443
{
443444
memcpy(p, &val, sizeof(val));
444445
}
@@ -576,6 +577,16 @@ adaptive_counter_backoff(_Py_BackoffCounter counter) {
576577
return restart_backoff_counter(counter);
577578
}
578579

580+
/* Specialization Extensions */
581+
582+
/* callbacks for an external specialization */
583+
typedef int (*binaryopguardfunc)(PyObject *lhs, PyObject *rhs);
584+
typedef PyObject *(*binaryopactionfunc)(PyObject *lhs, PyObject *rhs);
585+
586+
typedef struct {
587+
binaryopguardfunc guard;
588+
binaryopactionfunc action;
589+
} _PyBinaryOpSpecializationDescr;
579590

580591
/* Comparison bit masks. */
581592

Include/internal/pycore_dict.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,7 @@ PyDictObject *_PyObject_MaterializeManagedDict_LockHeld(PyObject *);
347347
static inline Py_ssize_t
348348
_PyDict_UniqueId(PyDictObject *mp)
349349
{
350-
// Offset by one so that _ma_watcher_tag=0 represents an unassigned id
351-
return (Py_ssize_t)(mp->_ma_watcher_tag >> DICT_UNIQUE_ID_SHIFT) - 1;
350+
return (Py_ssize_t)(mp->_ma_watcher_tag >> DICT_UNIQUE_ID_SHIFT);
352351
}
353352

354353
static inline void

0 commit comments

Comments
 (0)