8000 Merge 'origin/main' into gc_check_rss · python/cpython@6bb5797 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6bb5797

Browse files
committed
Merge 'origin/main' into gc_check_rss
2 parents ff2882e + 082dbf7 commit 6bb5797

File tree

109 files changed

+1881
-812
lines changed

Some content is hidden

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

109 files changed

+1881
-812
lines changed

.github/workflows/reusable-context.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ jobs:
9797
run: python Tools/build/compute-changes.py
9898
env:
9999
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
100+
CCF_TARGET_REF: ${{ github.base_ref || github.event.repository.default_branch }}
101+
CCF_HEAD_REF: ${{ github.event.pull_request.head.sha || github.sha }}
100102

101103
- name: Compute hash for config cache key
102104
id: config-hash

Doc/deprecations/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Deprecations
77

88
.. include:: pending-removal-in-3.17.rst
99

10+
.. include:: pending-removal-in-3.19.rst
11+
1012
.. include:: pending-removal-in-future.rst
1113

1214
C API deprecations
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Pending removal in Python 3.19
2+
------------------------------
3+
4+
* :mod:`ctypes`:
5+
6+
* Implicitly switching to the MSVC-compatible struct layout by setting
7+
:attr:`~ctypes.Structure._pack_` but not :attr:`~ctypes.Structure._layout_`
8+
on non-Windows platforms.

Doc/library/asyncio-eventloop.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ Creating Futures and Tasks
361361

362362
.. versionadded:: 3.5.2
363363

364-
.. method:: loop.create_task(coro, *, name=None, context=None)
364+
.. method:: loop.create_task(coro, *, name=None, context=None, eager_start=None)
365365

366366
Schedule the execution of :ref:`coroutine <coroutine>` *coro*.
367367
Return a :class:`Task` object.
@@ -377,12 +377,20 @@ Creating Futures and Tasks
377377
custom :class:`contextvars.Context` for the *coro* to run in.
378378
The current context copy is created when no *context* is provided.
379379

380+
An optional keyword-only *eager_start* argument allows specifying
381+
if the task should execute eagerly during the call to create_task,
382+
or be scheduled later. If *eager_start* is not passed the mode set
383+
by :meth:`loop.set_task_factory` will be used.
384+
380385
.. versionchanged:: 3.8
381386
Added the *name* parameter.
382387

383388
.. versionchanged:: 3.11
384389
Added the *context* parameter.
385390

391+
.. versionchanged:: next
392+
Added the *eager_start* parameter.
393+
386394
.. method:: loop.set_task_factory(factory)
387395

388396
Set a task factory that will be used by

Doc/library/ctypes.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2754,6 +2754,16 @@ fields, or any other data types containing pointer type fields.
27542754
when :attr:`_fields_` is assigned, otherwise it will have no effect.
27552755
Setting this attribute to 0 is the same as not setting it at all.
27562756

2757+
This is only implemented for the MSVC-compatible memory layout.
2758+
2759+
.. deprecated-removed:: next 3.19
2760+
2761+
For historical reasons, if :attr:`!_pack_` is non-zero,
2762+
the MSVC-compatible layout will be used by default.
2763+
On non-Windows platforms, this default is deprecated and is slated to
2764+
become an error in Python 3.19.
2765+
If it is intended, set :attr:`~Structure._layout_` to ``'ms'``
2766+
explicitly.
27572767

27582768
.. attribute:: _align_
27592769

@@ -2782,12 +2792,15 @@ fields, or any other data types containing pointer type fields.
27822792
Currently the default will be:
27832793

27842794
- On Windows: ``"ms"``
2785-
- When :attr:`~Structure._pack_` is specified: ``"ms"``
2795+
- When :attr:`~Structure._pack_` is specified: ``"ms"``.
2796+
(This is deprecated; see :attr:`~Structure._pack_` documentation.)
27862797
- Otherwise: ``"gcc-sysv"``
27872798

27882799
:attr:`!_layout_` must already be defined when
27892800
:attr:`~Structure._fields_` is assigned, otherwise it will have no effect.
27902801

2802+
.. versionadded:: next
2803+
27912804
.. attribute:: _anonymous_
27922805

27932806
An optional sequence that lists the names of unnamed (anonymous) fields.

Doc/library/heapq.rst

Lines changed: 88 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,56 @@
1616
This module provides an implementation of the heap queue algorithm, also known
1717
as the priority queue algorithm.
1818

19-
Heaps are binary trees for which every parent node has a value less than or
20-
equal to any of its children. We refer to this condition as the heap invariant.
19+
Min-heaps are binary trees for which every parent node has a value less than
20+
or equal to any of its children.
21+
We refer to this condition as the heap invariant.
2122

22-
This implementation uses arrays for which
23-
``heap[k] <= heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]`` for all *k*, counting
24-
elements from zero. For the sake of comparison, non-existing elements are
25-
considered to be infinite. The interesting property of a heap is that its
26-
smallest element is always the root, ``heap[0]``.
23+
For min-heaps, this implementation uses lists for which
24+
``heap[k] <= heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]`` for all *k* for which
25+
the compared elements exist. Elements are counted from zero. The interesting
26+
property of a min-heap is that its smallest element is always the root,
27+
``heap[0]``.
2728

28-
The API below differs from textbook heap algorithms in two aspects: (a) We use
29-
zero-based indexing. This makes the relationship between the index for a node
30-
and the indexes for its children slightly less obvious, but is more suitable
31-
since Python uses zero-based indexing. (b) Our pop method returns the smallest
32-
item, not the largest (called a "min heap" in textbooks; a "max heap" is more
33-
common in texts because of its suitability for in-place sorting).
29+
Max-heaps satisfy the reverse invariant: every parent node has a value
30+
*greater* than any of its children. These are implemented as lists for which
31+
``maxheap[2*k+1] <= maxheap[k]`` and ``maxheap[2*k+2] <= maxheap[k]`` for all
32+
*k* for which the compared elements exist.
33+
The root, ``maxheap[0]``, contains the *largest* element;
34+
``heap.sort(reverse=True)`` maintains the max-heap invariant.
3435

35-
These two make it possible to view the heap as a regular Python list without
36-
surprises: ``heap[0]`` is the smallest item, and ``heap.sort()`` maintains the
37-
heap invariant!
36+
The :mod:`!heapq` API differs from textbook heap algorithms in two aspects: (a)
37+
We use zero-based indexing. This makes the relationship between the index for
38+
a node and the indexes for its children slightly less obvious, but is more
39+
suitable since Python uses zero-based indexing. (b) Textbooks often focus on
40+
max-heaps, due to their suitability for in-place sorting. Our implementation
41+
favors min-heaps as they better correspond to Python :class:`lists <list>`.
3842

39-
To create a heap, use a list initialized to ``[]``, or you can transform a
40-
populated list into a heap via function :func:`heapify`.
43+
These two aspects make it possible to view the heap as a regular Python list
44+
without surprises: ``heap[0]`` is the smallest item, and ``heap.sort()``
45+
maintains the heap invariant!
4146

42-
The following functions are provided:
47+
Like :meth:`list.sort`, this implementation uses only the ``<`` operator
48+
for comparisons, for both min-heaps and max-heaps.
49+
50+
In the API below, and in this documentation, the unqualified term *heap*
51+
generally refers to a min-heap.
52+
The API for max-heaps is named using a ``_max`` suffix.
53+
54+
To create a heap, use a list initialized as ``[]``, or transform an existing list
55+
into a min-heap or max-heap using the :func:`heapify` or :func:`heapify_max`
56+
functions, respectively.
57+
58+
The following functions are provided for min-heaps:
4359

4460

4561
.. function:: heappush(heap, item)
4662

47-
Push the value *item* onto the *heap*, maintaining the heap invariant.
63+
Push the value *item* onto the *heap*, maintaining the min-heap invariant.
4864

4965

5066
.. function:: heappop(heap)
5167

52-
Pop and return the smallest item from the *heap*, maintaining the heap
68+
Pop and return the smallest item from the *heap*, maintaining the min-heap
5369
invariant. If the heap is empty, :exc:`IndexError` is raised. To access the
5470
smallest item without popping it, use ``heap[0]``.
5571

@@ -63,7 +79,7 @@ The following functions are provided:
6379

6480
.. function:: heapify(x)
6581

66-
Transform list *x* into a heap, in-place, in linear time.
82+
Transform list *x* into a min-heap, in-place, in linear time.
6783

6884

6985
.. function:: heapreplace(heap, item)
@@ -82,6 +98,56 @@ The following functions are provided:
8298
on the heap.
8399

84100

101+
For max-heaps, the following functions are provided:
102+
103+
104+
.. function:: heapify_max(x)
105+
106+
Transform list *x* into a max-heap, in-place, in linear time.
107+
108+
.. versionadded:: next
109+
110+
111+
.. function:: heappush_max(heap, item)
112+
113+
Push the value *item* onto the max-heap *heap*, maintaining the max-heap
114+
invariant.
115+
116+
.. versionadded:: next
117+
118+
119+
.. function:: heappop_max(heap)
120+
121+
Pop and return the largest item from the max-heap *heap*, maintaining the
122+
max-heap invariant. If the max-heap is empty, :exc:`IndexError` is raised.
123+
To access the largest item without popping it, use ``maxheap[0]``.
124+
125+
.. versionadded:: next
126+
127+
128+
.. function:: heappushpop_max(heap, item)
129+
130+
Push *item* on the max-heap *heap*, then pop and return the largest item
131+
from *heap*.
132+
The combined action runs more efficiently than :func:`heappush_max`
133+
followed by a separate call to :func:`heappop_max`.
134+
135+
.. versionadded:: next
136+
137+
138+
.. function:: heapreplace_max(heap, item)
139+
140+
Pop and return the largest item from the max-heap *heap* and also push the
141+
new *item*.
142+
The max-heap size doesn't change. If the max-heap is empty,
143+
:exc:`IndexError` is raised.
144+
145+
The value returned may be smaller than the *item* added. Refer to the
146+
analogous function :func:`heapreplace` for detailed usage notes.
147+
148+
.. versionadded:: next
149+
150+
85151
The module also offers three general purpose functions based on heaps.
86152

87153

Doc/library/pdb.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ The ``run*`` functions and :func:`set_trace` are aliases for instantiating the
243243
access further features, you have to do this yourself:
244244

245245
.. class:: Pdb(completekey='tab', stdin=None, stdout=None, skip=None, \
246-
nosigint=False, readrc=True, mode=None, backend=None)
246+
nosigint=False, readrc=True, mode=None, backend=None, colorize=False)
247247

248248
:class:`Pdb` is the debugger class.
249249

@@ -273,6 +273,9 @@ access further features, you have to do this yourself:
273273
is passed, the default backend will be used. See :func:`set_default_backend`.
274274
Otherwise the supported backends are ``'settrace'`` and ``'monitoring'``.
275275

276+
The *colorize* argument, if set to ``True``, will enable colorized output in the
277+
debugger, if color is supported. This will highlight source code displayed in pdb.
278+
276279
Example call to enable tracing with *skip*::
277280

278281
import pdb; pdb.Pdb(skip=['django.*']).set_trace()
@@ -295,6 +298,9 @@ access further features, you have to do this yourself:
295298
.. versionadded:: 3.14
296299
Added the *backend* argument.
297300

301+
.. versionadded:: 3.14
302+
Added the *colorize* argument.
303+
298304
.. versionchanged:: 3.14
299305
Inline breakpoints like :func:`breakpoint` or :func:`pdb.set_trace` will
300306
always stop the program at calling frame, ignoring the *skip* pattern (if any).

Doc/library/subprocess.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,24 @@ handling consistency are valid for these functions.
15251525
Notes
15261526
-----
15271527

1528+
.. _subprocess-timeout-behavior:
1529+
1530+
Timeout Behavior
1531+
^^^^^^^^^^^^^^^^
1532+
1533+
When using the ``timeout`` parameter in functions like :func:`run`,
1534+
:meth:`Popen.wait`, or :meth:`Popen.communicate`,
1535+
users should be aware of the following behaviors:
1536+
1537+
1. **Process Creation Delay**: The initial process creation itself cannot be interrupted
1538+
on many platform APIs. This means that even when specifying a timeout, you are not
1539+
guaranteed to see a timeout exception until at least after however long process
1540+
creation takes.
1541+
1542+
2. **Extremely Small Timeout Values**: Setting very small timeout values (such as a few
1543+
milliseconds) may result in almost immediate :exc:`TimeoutExpired` exceptions because
1544+
process creation and system scheduling inherently require time.
1545+
15281546
.. _converting-argument-sequence:
15291547

15301548
Converting an argument sequence to a string on Windows

0 commit comments

Comments
 (0)
0