Skip to content

Commit 7e067e3

Browse files
Merge branch 'main' into gh-132042-precalc-mro-dict
2 parents a64d3a0 + 741c638 commit 7e067e3

Some content is hidden

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

65 files changed

+1794
-1112
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.9.1
3+
rev: v0.11.4
44
hooks:
55
- id: ruff
66
name: Run Ruff (lint) on Doc/

Doc/howto/perf_profiling.rst

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,28 @@ files in the current directory which are ELF images for all the JIT trampolines
254254
that were created by Python.
255255

256256
.. warning::
257-
Notice that when using ``--call-graph dwarf`` the ``perf`` tool will take
257+
When using ``--call-graph dwarf``, the ``perf`` tool will take
258258
snapshots of the stack of the process being profiled and save the
259-
information in the ``perf.data`` file. By default the size of the stack dump
260-
is 8192 bytes but the user can change the size by passing the size after
261-
comma like ``--call-graph dwarf,4096``. The size of the stack dump is
262-
important because if the size is too small ``perf`` will not be able to
263-
unwind the stack and the output will be incomplete. On the other hand, if
264-
the size is too big, then ``perf`` won't be able to sample the process as
265-
frequently as it would like as the overhead will be higher.
259+
information in the ``perf.data`` file. By default, the size of the stack dump
260+
is 8192 bytes, but you can change the size by passing it after
261+
a comma like ``--call-graph dwarf,16384``.
266262

263+
The size of the stack dump is important because if the size is too small
264+
``perf`` will not be able to unwind the stack and the output will be
265+
incomplete. On the other hand, if the size is too big, then ``perf`` won't
266+
be able to sample the process as frequently as it would like as the overhead
267+
will be higher.
268+
269+
The stack size is particularly important when profiling Python code compiled
270+
with low optimization levels (like ``-O0``), as these builds tend to have
271+
larger stack frames. If you are compiling Python with ``-O0`` and not seeing
272+
Python functions in your profiling output, try increasing the stack dump
273+
size to 65528 bytes (the maximum)::
274+
275+
$ perf record -F 9999 -g -k 1 --call-graph dwarf,65528 -o perf.data python -Xperf_jit my_script.py
276+
277+
Different compilation flags can significantly impact stack sizes:
278+
279+
- Builds with ``-O0`` typically have much larger stack frames than those with ``-O1`` or higher
280+
- Adding optimizations (``-O1``, ``-O2``, etc.) typically reduces stack size
281+
- Frame pointers (``-fno-omit-frame-pointer``) generally provide more reliable stack unwinding

Doc/library/dis.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,9 +1354,6 @@ iterations of the loop.
13541354
If ``STACK[-1]`` is not ``None``, increments the bytecode counter by *delta*.
13551355
``STACK[-1]`` is popped.
13561356

1357-
This opcode is a pseudo-instruction, replaced in final bytecode by
1358-
the directed versions (forward/backward).
1359-
13601357
.. versionadded:: 3.11
13611358

13621359
.. versionchanged:: 3.12
@@ -1368,9 +1365,6 @@ iterations of the loop.
13681365
If ``STACK[-1]`` is ``None``, increments the bytecode counter by *delta*.
13691366
``STACK[-1]`` is popped.
13701367

1371-
This opcode is a pseudo-instruction, replaced in final bytecode by
1372-
the directed versions (forward/backward).
1373-
13741368
.. versionadded:: 3.11
13751369

13761370
.. versionchanged:: 3.12

Doc/library/itertools.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,12 @@ The following recipes have a more mathematical flavor:
10091009

10101010
.. testcode::
10111011

1012+
def multinomial(*counts):
1013+
"Number of distinct arrangements of a multiset."
1014+
# Counter('abracadabra').values() → 5 2 2 1 1
1015+
# multinomial(5, 2, 2, 1, 1) → 83160
1016+
return prod(map(comb, accumulate(counts), counts))
1017+
10121018
def powerset(iterable):
10131019
"Subsequences of the iterable from shortest to longest."
10141020
# powerset([1,2,3]) → () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)
@@ -1127,12 +1133,6 @@ The following recipes have a more mathematical flavor:
11271133
n -= n // prime
11281134
return n
11291135

1130-
def multinomial(*counts):
1131-
"Number of distinct arrangements of a multiset."
1132-
# Counter('abracadabra').values() → 5 2 2 1 1
1133-
# multinomial(5, 2, 2, 1, 1) → 83160
1134-
return prod(map(comb, accumulate(counts), counts))
1135-
11361136

11371137
.. doctest::
11381138
:hide:

Doc/tools/templates/layout.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727

2828
{% block extrahead %}
2929
{% if builder == "html" and enable_analytics %}
30-
<script defer data-domain="docs.python.org" src="https://plausible.io/js/script.js"></script>
31-
<script defer data-domain="docs.python.org" src="https://analytics.python.org/js/script.js"></script>
30+
<script defer data-domain="docs.python.org" src="https://analytics.python.org/js/script.outbound-links.js"></script>
3231
{% endif %}
3332
<link rel="canonical" href="https://docs.python.org/3/{{pagename}}.html">
3433
{% if builder != "htmlhelp" %}

Doc/using/cmdline.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ source.
7373

7474
.. audit-event:: cpython.run_command command cmdoption-c
7575

76+
.. versionchanged:: next
77+
*command* is automatically dedented before execution.
78+
7679
.. option:: -m <module-name>
7780

7881
Search :data:`sys.path` for the named module and execute its contents as

Doc/whatsnew/3.14.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,12 @@ Other language changes
474474
explicitly overridden in the subclass.
475475
(Contributed by Tomasz Pytel in :gh:`132329`.)
476476

477+
* The command line option :option:`-c` now automatically dedents its code
478+
argument before execution. The auto-dedentation behavior mirrors
479+
:func:`textwrap.dedent`.
480+
(Contributed by Jon Crall and Steven Sun in :gh:`103998`.)
481+
482+
477483
.. _whatsnew314-pep765:
478484

479485
PEP 765: Disallow return/break/continue that exit a finally block

Include/internal/pycore_emscripten_trampoline.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,18 @@ _PyEM_TrampolineCall(PyCFunctionWithKeywords func,
3737
PyObject* kw);
3838

3939
#define _PyCFunction_TrampolineCall(meth, self, args) \
40-
_PyEM_TrampolineCall( \
41-
(*(PyCFunctionWithKeywords)(void(*)(void))(meth)), (self), (args), NULL)
40+
_PyEM_TrampolineCall(*_PyCFunctionWithKeywords_CAST(meth), (self), (args), NULL)
4241

4342
#define _PyCFunctionWithKeywords_TrampolineCall(meth, self, args, kw) \
4443
_PyEM_TrampolineCall((meth), (self), (args), (kw))
4544

46-
#define descr_set_trampoline_call(set, obj, value, closure) \
47-
((int)_PyEM_TrampolineCall((PyCFunctionWithKeywords)(set), (obj), (value), (PyObject*)(closure)))
45+
#define descr_set_trampoline_call(set, obj, value, closure) \
46+
((int)_PyEM_TrampolineCall(_PyCFunctionWithKeywords_CAST(set), (obj), \
47+
(value), (PyObject*)(closure)))
4848

49-
#define descr_get_trampoline_call(get, obj, closure) \
50-
_PyEM_TrampolineCall((PyCFunctionWithKeywords)(get), (obj), (PyObject*)(closure), NULL)
49+
#define descr_get_trampoline_call(get, obj, closure) \
50+
_PyEM_TrampolineCall(_PyCFunctionWithKeywords_CAST(get), (obj), \
51+
(PyObject*)(closure), NULL)
5152

5253

5354
#else // defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)

Include/internal/pycore_unicodeobject.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ extern Py_ssize_t _PyUnicode_InsertThousandsGrouping(
247247
Py_UCS4 *maxchar,
248248
int forward);
249249

250+
/* Dedent a string.
251+
Behaviour is expected to be an exact match of `textwrap.dedent`.
252+
Return a new reference on success, NULL with exception set on error.
253+
*/
254+
extern PyObject* _PyUnicode_Dedent(PyObject *unicode);
255+
250256
/* --- Misc functions ----------------------------------------------------- */
251257

252258
extern PyObject* _PyUnicode_FormatLong(PyObject *, int, int, int);

Include/internal/pycore_uop_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)