Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ Misc/externals.spdx.json @sethmlarson
Misc/sbom.spdx.json @sethmlarson
Tools/build/generate_sbom.py @sethmlarson

# ABI check
Misc/libabigail.abignore @encukou


# ----------------------------------------------------------------------------
# Platform Support
Expand Down
21 changes: 21 additions & 0 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,27 @@ Python:
.. versionadded:: 3.3


The structure of a particular object can be determined using the following
macros.
The macros cannot fail; their behavior is undefined if their argument
is not a Python Unicode object.

.. c:namespace:: NULL
.. c:macro:: PyUnicode_IS_COMPACT(o)
True if *o* uses the :c:struct:`PyCompactUnicodeObject` structure.

.. versionadded:: 3.3


.. c:macro:: PyUnicode_IS_COMPACT_ASCII(o)
True if *o* uses the :c:struct:`PyASCIIObject` structure.

.. versionadded:: 3.3


The following APIs are C macros and static inlined functions for fast checks and
access to internal read-only data of Unicode objects:

Expand Down
20 changes: 20 additions & 0 deletions Doc/library/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ Module Contents

Return a list of all power-of-two integers contained in a flag.

:func:`enum.bin`

Like built-in :func:`bin`, except negative values are represented in
two's complement, and the leading bit always indicates sign
(``0`` implies positive, ``1`` implies negative).


.. versionadded:: 3.6 ``Flag``, ``IntFlag``, ``auto``
.. versionadded:: 3.11 ``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, ``member``, ``nonmember``, ``global_enum``, ``show_flag_values``
Expand Down Expand Up @@ -1035,6 +1041,20 @@ Utilities and Decorators

.. versionadded:: 3.11

.. function:: bin(num, max_bits=None)

Like built-in :func:`bin`, except negative values are represented in
two's complement, and the leading bit always indicates sign
(``0`` implies positive, ``1`` implies negative).

>>> import enum
>>> enum.bin(10)
'0b0 1010'
>>> enum.bin(~10) # ~10 is -11
'0b1 0101'

.. versionadded:: 3.10

---------------

Notes
Expand Down
2 changes: 2 additions & 0 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ are always available. They are listed here in alphabetical order.
>>> f'{14:#b}', f'{14:b}'
('0b1110', '1110')

See also :func:`enum.bin` to represent negative values as twos-complement.

See also :func:`format` for more information.


Expand Down
6 changes: 6 additions & 0 deletions Doc/library/readline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,9 @@ support history save/restore. ::
def save_history(self, histfile):
readline.set_history_length(1000)
readline.write_history_file(histfile)

.. note::

The new :term:`REPL` introduced in version 3.13 doesn't support readline.
However, readline can still be used by setting the :envvar:`PYTHON_BASIC_REPL`
environment variable.
103 changes: 103 additions & 0 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,109 @@ application).
list appear empty for the duration, and raises :exc:`ValueError` if it can
detect that the list has been mutated during a sort.

.. admonition:: Thread safety

Reading a single element from a :class:`list` is
:term:`atomic <atomic operation>`:

.. code-block::
:class: green

lst[i] # list.__getitem__

The following methods traverse the list and use :term:`atomic <atomic operation>`
reads of each item to perform their function. That means that they may
return results affected by concurrent modifications:

.. code-block::
:class: maybe

item in lst
lst.index(item)
lst.count(item)

All of the above methods/operations are also lock-free. They do not block
concurrent modifications. Other operations that hold a lock will not block
these from observing intermediate states.

All other operations from here on block using the per-object lock.

Writing a single item via ``lst[i] = x`` is safe to call from multiple
threads and will not corrupt the list.

The following operations return new objects and appear
:term:`atomic <atomic operation>` to other threads:

.. code-block::
:class: good

lst1 + lst2 # concatenates two lists into a new list
x * lst # repeats lst x times into a new list
lst.copy() # returns a shallow copy of the list

Methods that only operate on a single elements with no shifting required are
:term:`atomic <atomic operation>`:

.. code-block::
:class: good

lst.append(x) # append to the end of the list, no shifting required
lst.pop() # pop element from the end of the list, no shifting required

The :meth:`~list.clear` method is also :term:`atomic <atomic operation>`.
Other threads cannot observe elements being removed.

The :meth:`~list.sort` method is not :term:`atomic <atomic operation>`.
Other threads cannot observe intermediate states during sorting, but the
list appears empty for the duration of the sort.

The following operations may allow lock-free operations to observe
intermediate states since they modify multiple elements in place:

.. code-block::
:class: maybe

lst.insert(idx, item) # shifts elements
lst.pop(idx) # idx not at the end of the list, shifts elements
lst *= x # copies elements in place

The :meth:`~list.remove` method may allow concurrent modifications since
element comparison may execute arbitrary Python code (via
:meth:`~object.__eq__`).

:meth:`~list.extend` is safe to call from multiple threads. However, its
guarantees depend on the iterable passed to it. If it is a :class:`list`, a
:class:`tuple`, a :class:`set`, a :class:`frozenset`, a :class:`dict` or a
:ref:`dictionary view object <dict-views>` (but not their subclasses), the
``extend`` operation is safe from concurrent modifications to the iterable.
Otherwise, an iterator is created which can be concurrently modified by
another thread. The same applies to inplace concatenation of a list with
other iterables when using ``lst += iterable``.

Similarly, assigning to a list slice with ``lst[i:j] = iterable`` is safe
to call from multiple threads, but ``iterable`` is only locked when it is
also a :class:`list` (but not its subclasses).

Operations that involve multiple accesses, as well as iteration, are never
atomic. For example:

.. code-block::
:class: bad

# NOT atomic: read-modify-write
lst[i] = lst[i] + 1

# NOT atomic: check-then-act
if lst:
item = lst.pop()

# NOT thread-safe: iteration while modifying
for item in lst:
process(item) # another thread may modify lst

Consider external synchronization when sharing :class:`list` instances
across threads. See :ref:`freethreading-python-howto` for more information.


.. _typesseq-tuple:

Expand Down
12 changes: 6 additions & 6 deletions Doc/tutorial/interpreter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ status. If that doesn't work, you can exit the interpreter by typing the
following command: ``quit()``.

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

The interpreter operates somewhat like the Unix shell: when called with standard
Expand Down
16 changes: 8 additions & 8 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Include/internal/pycore_uop_ids.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading