Skip to content

Commit 2969891

Browse files
authored
Merge branch 'main' into feat/ADD_OP
2 parents 45f8ce0 + 7d155d7 commit 2969891

File tree

20 files changed

+579
-235
lines changed

20 files changed

+579
-235
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ Misc/externals.spdx.json @sethmlarson
143143
Misc/sbom.spdx.json @sethmlarson
144144
Tools/build/generate_sbom.py @sethmlarson
145145

146+
# ABI check
147+
Misc/libabigail.abignore @encukou
148+
146149

147150
# ----------------------------------------------------------------------------
148151
# Platform Support

Doc/library/readline.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,9 @@ support history save/restore. ::
403403
def save_history(self, histfile):
404404
readline.set_history_length(1000)
405405
readline.write_history_file(histfile)
406+
407+
.. note::
408+
409+
The new :term:`REPL` introduced in version 3.13 doesn't support readline.
410+
However, readline can still be used by setting the :envvar:`PYTHON_BASIC_REPL`
411+
environment variable.

Doc/library/stdtypes.rst

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,109 @@ application).
14411441
list appear empty for the duration, and raises :exc:`ValueError` if it can
14421442
detect that the list has been mutated during a sort.
14431443

1444+
.. admonition:: Thread safety
1445+
1446+
Reading a single element from a :class:`list` is
1447+
:term:`atomic <atomic operation>`:
1448+
1449+
.. code-block::
1450+
:class: green
1451+
1452+
lst[i] # list.__getitem__
1453+
1454+
The following methods traverse the list and use :term:`atomic <atomic operation>`
1455+
reads of each item to perform their function. That means that they may
1456+
return results affected by concurrent modifications:
1457+
1458+
.. code-block::
1459+
:class: maybe
1460+
1461+
item in lst
1462+
lst.index(item)
1463+
lst.count(item)
1464+
1465+
All of the above methods/operations are also lock-free. They do not block
1466+
concurrent modifications. Other operations that hold a lock will not block
1467+
these from observing intermediate states.
1468+
1469+
All other operations from here on block using the per-object lock.
1470+
1471+
Writing a single item via ``lst[i] = x`` is safe to call from multiple
1472+
threads and will not corrupt the list.
1473+
1474+
The following operations return new objects and appear
1475+
:term:`atomic <atomic operation>` to other threads:
1476+
1477+
.. code-block::
1478+
:class: good
1479+
1480+
lst1 + lst2 # concatenates two lists into a new list
1481+
x * lst # repeats lst x times into a new list
1482+
lst.copy() # returns a shallow copy of the list
1483+
1484+
Methods that only operate on a single elements with no shifting required are
1485+
:term:`atomic <atomic operation>`:
1486+
1487+
.. code-block::
1488+
:class: good
1489+
1490+
lst.append(x) # append to the end of the list, no shifting required
1491+
lst.pop() # pop element from the end of the list, no shifting required
1492+
1493+
The :meth:`~list.clear` method is also :term:`atomic <atomic operation>`.
1494+
Other threads cannot observe elements being removed.
1495+
1496+
The :meth:`~list.sort` method is not :term:`atomic <atomic operation>`.
1497+
Other threads cannot observe intermediate states during sorting, but the
1498+
list appears empty for the duration of the sort.
1499+
1500+
The following operations may allow lock-free operations to observe
1501+
intermediate states since they modify multiple elements in place:
1502+
1503+
.. code-block::
1504+
:class: maybe
1505+
1506+
lst.insert(idx, item) # shifts elements
1507+
lst.pop(idx) # idx not at the end of the list, shifts elements
1508+
lst *= x # copies elements in place
1509+
1510+
The :meth:`~list.remove` method may allow concurrent modifications since
1511+
element comparison may execute arbitrary Python code (via
1512+
:meth:`~object.__eq__`).
1513+
1514+
:meth:`~list.extend` is safe to call from multiple threads. However, its
1515+
guarantees depend on the iterable passed to it. If it is a :class:`list`, a
1516+
:class:`tuple`, a :class:`set`, a :class:`frozenset`, a :class:`dict` or a
1517+
:ref:`dictionary view object <dict-views>` (but not their subclasses), the
1518+
``extend`` operation is safe from concurrent modifications to the iterable.
1519+
Otherwise, an iterator is created which can be concurrently modified by
1520+
another thread. The same applies to inplace concatenation of a list with
1521+
other iterables when using ``lst += iterable``.
1522+
1523+
Similarly, assigning to a list slice with ``lst[i:j] = iterable`` is safe
1524+
to call from multiple threads, but ``iterable`` is only locked when it is
1525+
also a :class:`list` (but not its subclasses).
1526+
1527+
Operations that involve multiple accesses, as well as iteration, are never
1528+
atomic. For example:
1529+
1530+
.. code-block::
1531+
:class: bad
1532+
1533+
# NOT atomic: read-modify-write
1534+
lst[i] = lst[i] + 1
1535+
1536+
# NOT atomic: check-then-act
1537+
if lst:
1538+
item = lst.pop()
1539+
1540+
# NOT thread-safe: iteration while modifying
1541+
for item in lst:
1542+
process(item) # another thread may modify lst
1543+
1544+
Consider external synchronization when sharing :class:`list` instances
1545+
across threads. See :ref:`freethreading-python-howto` for more information.
1546+
14441547

14451548
.. _typesseq-tuple:
14461549

Doc/tutorial/interpreter.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ status. If that doesn't work, you can exit the interpreter by typing the
3434
following command: ``quit()``.
3535

3636
The interpreter's line-editing features include interactive editing, history
37-
substitution and code completion on systems that support the `GNU Readline
38-
<https://tiswww.case.edu/php/chet/readline/rltop.html>`_ library.
37+
substitution and code completion on most systems.
3938
Perhaps the quickest check to see whether command line editing is supported is
40-
typing :kbd:`Control-P` to the first Python prompt you get. If it beeps, you
41-
have command line editing; see Appendix :ref:`tut-interacting` for an
42-
introduction to the keys. If nothing appears to happen, or if ``^P`` is
43-
echoed, command line editing isn't available; you'll only be able to use
39+
typing a word in on the Python prompt, then pressing Left arrow (or :kbd:`Control-b`).
40+
If the cursor moves, you have command line editing; see Appendix
41+
:ref:`tut-interacting` for an introduction to the keys.
42+
If nothing appears to happen, or if a sequence like ``^[[D`` or ``^B`` appears,
43+
command line editing isn't available; you'll only be able to use
4444
backspace to remove characters from the current line.
4545

4646
The interpreter operates somewhat like the Unix shell: when called with standard

Include/internal/pycore_opcode_metadata.h

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_ids.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)