Skip to content

Commit 0db663d

Browse files
Merge remote-tracking branch 'upstream/main' into tidy-jit-invariants
2 parents ba708ca + daa9aa4 commit 0db663d

File tree

124 files changed

+3518
-1979
lines changed

Some content is hidden

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

124 files changed

+3518
-1979
lines changed

Doc/c-api/module.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ A module's token -- and the *your_token* value to use in the above code -- is:
571571
of that slot;
572572
- For modules created from an ``PyModExport_*``
573573
:ref:`export hook <extension-export-hook>`: the slots array that the export
574-
hook returned (unless overriden with :c:macro:`Py_mod_token`).
574+
hook returned (unless overridden with :c:macro:`Py_mod_token`).
575575
576576
.. c:macro:: Py_mod_token
577577

Doc/library/base64.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,20 @@ Refer to the documentation of the individual functions for more information.
267267
.. versionadded:: 3.4
268268

269269

270-
.. function:: z85encode(s)
270+
.. function:: z85encode(s, pad=False)
271271

272272
Encode the :term:`bytes-like object` *s* using Z85 (as used in ZeroMQ)
273273
and return the encoded :class:`bytes`. See `Z85 specification
274274
<https://rfc.zeromq.org/spec/32/>`_ for more information.
275275

276+
If *pad* is true, the input is padded with ``b'\0'`` so its length is a
277+
multiple of 4 bytes before encoding.
278+
276279
.. versionadded:: 3.13
277280

281+
.. versionchanged:: next
282+
The *pad* parameter was added.
283+
278284

279285
.. function:: z85decode(s)
280286

Doc/library/inspect.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
273273
+-----------------+-------------------+---------------------------+
274274
| | ag_running | is the generator running? |
275275
+-----------------+-------------------+---------------------------+
276+
| | ag_suspended | is the generator |
277+
| | | suspended? |
278+
+-----------------+-------------------+---------------------------+
276279
| | ag_code | code |
277280
+-----------------+-------------------+---------------------------+
278281
| coroutine | __name__ | name |
@@ -286,6 +289,9 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
286289
+-----------------+-------------------+---------------------------+
287290
| | cr_running | is the coroutine running? |
288291
+-----------------+-------------------+---------------------------+
292+
| | cr_suspended | is the coroutine |
293+
| | | suspended? |
294+
+-----------------+-------------------+---------------------------+
289295
| | cr_code | code |
290296
+-----------------+-------------------+---------------------------+
291297
| | cr_origin | where coroutine was |
@@ -319,6 +325,18 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
319325

320326
Add ``__builtins__`` attribute to functions.
321327

328+
.. versionchanged:: 3.11
329+
330+
Add ``gi_suspended`` attribute to generators.
331+
332+
.. versionchanged:: 3.11
333+
334+
Add ``cr_suspended`` attribute to coroutines.
335+
336+
.. versionchanged:: 3.12
337+
338+
Add ``ag_suspended`` attribute to async generators.
339+
322340
.. versionchanged:: 3.14
323341

324342
Add ``f_generator`` attribute to frames.

Doc/library/linecache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The :mod:`linecache` module defines the following functions:
3131
.. index:: triple: module; search; path
3232

3333
If *filename* indicates a frozen module (starting with ``'<frozen '``), the function
34-
will attepmt to get the real file name from ``module_globals['__file__']`` if
34+
will attempt to get the real file name from ``module_globals['__file__']`` if
3535
*module_globals* is not ``None``.
3636

3737
If a file named *filename* is not found, the function first checks

Doc/library/logging.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,11 @@ the options available to you.
10111011
| exc_info | You shouldn't need to | Exception tuple (à la ``sys.exc_info``) or, |
10121012
| | format this yourself. | if no exception has occurred, ``None``. |
10131013
+----------------+-------------------------+-----------------------------------------------+
1014+
| exc_text | You shouldn't need to | Exception information formatted as a string. |
1015+
| | format this yourself. | This is set when :meth:`Formatter.format` is |
1016+
| | | invoked, or ``None`` if no exception has |
1017+
| | | occurred. |
1018+
+----------------+-------------------------+-----------------------------------------------+
10141019
| filename | ``%(filename)s`` | Filename portion of ``pathname``. |
10151020
+----------------+-------------------------+-----------------------------------------------+
10161021
| funcName | ``%(funcName)s`` | Name of function containing the logging call. |

Doc/library/mmap.rst

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
212212
Writable :term:`bytes-like object` is now accepted.
213213

214214

215-
.. method:: flush([offset[, size]])
215+
.. method:: flush([offset[, size]], *, flags=MS_SYNC)
216216

217217
Flushes changes made to the in-memory copy of a file back to disk. Without
218218
use of this call there is no guarantee that changes are written back before
@@ -221,6 +221,12 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
221221
whole extent of the mapping is flushed. *offset* must be a multiple of the
222222
:const:`PAGESIZE` or :const:`ALLOCATIONGRANULARITY`.
223223

224+
The *flags* parameter specifies the synchronization behavior.
225+
*flags* must be one of the :ref:`MS_* constants <ms-constants>` available
226+
on the system.
227+
228+
On Windows, the *flags* parameter is ignored.
229+
224230
``None`` is returned to indicate success. An exception is raised when the
225231
call failed.
226232

@@ -235,6 +241,9 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
235241
specified alone, and the flush operation will extend from *offset*
236242
to the end of the mmap.
237243

244+
.. versionchanged:: next
245+
Added *flags* parameter to control synchronization behavior.
246+
238247

239248
.. method:: madvise(option[, start[, length]])
240249

@@ -461,3 +470,22 @@ MAP_* Constants
461470
:data:`MAP_TPRO`, :data:`MAP_TRANSLATED_ALLOW_EXECUTE`, and
462471
:data:`MAP_UNIX03` constants.
463472

473+
.. _ms-constants:
474+
475+
MS_* Constants
476+
++++++++++++++
477+
478+
.. data:: MS_SYNC
479+
MS_ASYNC
480+
MS_INVALIDATE
481+
482+
These flags control the synchronization behavior for :meth:`mmap.flush`:
483+
484+
* :data:`MS_SYNC` - Synchronous flush: writes are scheduled and the call
485+
blocks until they are physically written to storage.
486+
* :data:`MS_ASYNC` - Asynchronous flush: writes are scheduled but the call
487+
returns immediately without waiting for completion.
488+
* :data:`MS_INVALIDATE` - Invalidate cached data: invalidates other mappings
489+
of the same file so they can see the changes.
490+
491+
.. versionadded:: next

Doc/library/os.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5993,7 +5993,7 @@ Miscellaneous System Information
59935993

59945994
.. versionchanged:: 3.13
59955995
If :option:`-X cpu_count <-X>` is given or :envvar:`PYTHON_CPU_COUNT` is set,
5996-
:func:`cpu_count` returns the overridden value *n*.
5996+
:func:`cpu_count` returns the override value *n*.
59975997

59985998

59995999
.. function:: getloadavg()
@@ -6015,7 +6015,7 @@ Miscellaneous System Information
60156015
in the **system**.
60166016

60176017
If :option:`-X cpu_count <-X>` is given or :envvar:`PYTHON_CPU_COUNT` is set,
6018-
:func:`process_cpu_count` returns the overridden value *n*.
6018+
:func:`process_cpu_count` returns the override value *n*.
60196019

60206020
See also the :func:`sched_getaffinity` function.
60216021

Doc/library/profiling.sampling.rst

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ counts**, not direct measurements. Tachyon counts how many times each function
5353
appears in the collected samples, then multiplies by the sampling interval to
5454
estimate time.
5555

56-
For example, with a 100 microsecond sampling interval over a 10-second profile,
56+
For example, with a 10 kHz sampling rate over a 10-second profile,
5757
Tachyon collects approximately 100,000 samples. If a function appears in 5,000
5858
samples (5% of total), Tachyon estimates it consumed 5% of the 10-second
5959
duration, or about 500 milliseconds. This is a statistical estimate, not a
@@ -142,7 +142,7 @@ Use live mode for real-time monitoring (press ``q`` to quit)::
142142

143143
Profile for 60 seconds with a faster sampling rate::
144144

145-
python -m profiling.sampling run -d 60 -i 50 script.py
145+
python -m profiling.sampling run -d 60 -r 20khz script.py
146146

147147
Generate a line-by-line heatmap::
148148

@@ -241,8 +241,8 @@ is unaware it is being profiled.
241241
When profiling production systems, keep these guidelines in mind:
242242

243243
Start with shorter durations (10-30 seconds) to get quick results, then extend
244-
if you need more statistical accuracy. The default 10-second duration is usually
245-
sufficient to identify major hotspots.
244+
if you need more statistical accuracy. By default, profiling runs until the
245+
target process completes, which is usually sufficient to identify major hotspots.
246246

247247
If possible, profile during representative load rather than peak traffic.
248248
Profiles collected during normal operation are easier to interpret than those
@@ -326,10 +326,10 @@ The default configuration works well for most use cases:
326326

327327
* - Option
328328
- Default
329-
* - Default for ``--interval`` / ``-i``
330-
- 100 µs between samples (~10,000 samples/sec)
329+
* - Default for ``--sampling-rate`` / ``-r``
330+
- 1 kHz
331331
* - Default for ``--duration`` / ``-d``
332-
- 10 seconds
332+
- Run to completion
333333
* - Default for ``--all-threads`` / ``-a``
334334
- Main thread only
335335
* - Default for ``--native``
@@ -346,33 +346,31 @@ The default configuration works well for most use cases:
346346
- Disabled (non-blocking sampling)
347347

348348

349-
Sampling interval and duration
350-
------------------------------
349+
Sampling rate and duration
350+
--------------------------
351351

352-
The two most fundamental parameters are the sampling interval and duration.
352+
The two most fundamental parameters are the sampling rate and duration.
353353
Together, these determine how many samples will be collected during a profiling
354354
session.
355355

356-
The :option:`--interval` option (:option:`-i`) sets the time between samples in
357-
microseconds. The default is 100 microseconds, which produces approximately
358-
10,000 samples per second::
356+
The :option:`--sampling-rate` option (:option:`-r`) sets how frequently samples
357+
are collected. The default is 1 kHz (10,000 samples per second)::
359358

360-
python -m profiling.sampling run -i 50 script.py
359+
python -m profiling.sampling run -r 20khz script.py
361360

362-
Lower intervals capture more samples and provide finer-grained data at the
363-
cost of slightly higher profiler CPU usage. Higher intervals reduce profiler
361+
Higher rates capture more samples and provide finer-grained data at the
362+
cost of slightly higher profiler CPU usage. Lower rates reduce profiler
364363
overhead but may miss short-lived functions. For most applications, the
365-
default interval provides a good balance between accuracy and overhead.
364+
default rate provides a good balance between accuracy and overhead.
366365

367-
The :option:`--duration` option (:option:`-d`) sets how long to profile in seconds. The
368-
default is 10 seconds::
366+
The :option:`--duration` option (:option:`-d`) sets how long to profile in seconds. By
367+
default, profiling continues until the target process exits or is interrupted::
369368

370369
python -m profiling.sampling run -d 60 script.py
371370

372-
Longer durations collect more samples and produce more statistically reliable
373-
results, especially for code paths that execute infrequently. When profiling
374-
a program that runs for a fixed time, you may want to set the duration to
375-
match or exceed the expected runtime.
371+
Specifying a duration is useful when attaching to long-running processes or when
372+
you want to limit profiling to a specific time window. When profiling a script,
373+
the default behavior of running to completion is usually what you want.
376374

377375

378376
Thread selection
@@ -573,9 +571,9 @@ appended:
573571
- For pstats format (which defaults to stdout), subprocesses produce files like
574572
``profile_12345.pstats``
575573

576-
The subprocess profilers inherit most sampling options from the parent (interval,
577-
duration, thread selection, native frames, GC frames, async-aware mode, and
578-
output format). All Python descendant processes are profiled recursively,
574+
The subprocess profilers inherit most sampling options from the parent (sampling
575+
rate, duration, thread selection, native frames, GC frames, async-aware mode,
576+
and output format). All Python descendant processes are profiled recursively,
579577
including grandchildren and further descendants.
580578

581579
Subprocess detection works by periodically scanning for new descendants of
@@ -1389,13 +1387,13 @@ Global options
13891387
Sampling options
13901388
----------------
13911389

1392-
.. option:: -i <microseconds>, --interval <microseconds>
1390+
.. option:: -r <rate>, --sampling-rate <rate>
13931391

1394-
Sampling interval in microseconds. Default: 100.
1392+
Sampling rate (for example, ``10000``, ``10khz``, ``10k``). Default: ``1khz``.
13951393

13961394
.. option:: -d <seconds>, --duration <seconds>
13971395

1398-
Profiling duration in seconds. Default: 10.
1396+
Profiling duration in seconds. Default: run to completion.
13991397

14001398
.. option:: -a, --all-threads
14011399

Doc/library/zoneinfo.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ The ``ZoneInfo`` class has two alternate constructors:
206206

207207
Objects created via this constructor cannot be pickled (see `pickling`_).
208208

209+
:exc:`ValueError` is raised if the data read from *file_obj* is not a valid
210+
TZif file.
211+
209212
.. classmethod:: ZoneInfo.no_cache(key)
210213

211214
An alternate constructor that bypasses the constructor's cache. It is

Doc/tools/extensions/grammar_snippet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class GrammarSnippetDirective(GrammarSnippetBase):
191191
into something similar to Sphinx productionlist, but better suited
192192
for our needs:
193193
- Instead of `::=`, use a colon, as in `Grammar/python.gram`
194-
- Show the listing almost as is, with no auto-aligment.
194+
- Show the listing almost as is, with no auto-alignment.
195195
The only special character is the backtick, which marks tokens.
196196
197197
Unlike Sphinx's productionlist, this directive supports options.

0 commit comments

Comments
 (0)