Skip to content

Commit 618cb4f

Browse files
authored
Merge branch 'main' into feat/ADD_OP
2 parents 25797cf + 42f7c2d commit 618cb4f

46 files changed

Lines changed: 1417 additions & 1001 deletions

Some content is hidden

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

Doc/c-api/apiabiversion.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ See :ref:`stable` for a discussion of API and ABI stability across versions.
6767
6868
The Python version as a string, for example, ``"3.4.1a2"``.
6969

70+
These macros are defined in :source:`Include/patchlevel.h`.
71+
7072

7173
Run-time version
7274
----------------

Doc/c-api/unicode.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,27 @@ Python:
6565
.. versionadded:: 3.3
6666

6767

68+
The structure of a particular object can be determined using the following
69+
macros.
70+
The macros cannot fail; their behavior is undefined if their argument
71+
is not a Python Unicode object.
72+
73+
.. c:namespace:: NULL
74+
75+
.. c:macro:: PyUnicode_IS_COMPACT(o)
76+
77+
True if *o* uses the :c:struct:`PyCompactUnicodeObject` structure.
78+
79+
.. versionadded:: 3.3
80+
81+
82+
.. c:macro:: PyUnicode_IS_COMPACT_ASCII(o)
83+
84+
True if *o* uses the :c:struct:`PyASCIIObject` structure.
85+
86+
.. versionadded:: 3.3
87+
88+
6889
The following APIs are C macros and static inlined functions for fast checks and
6990
access to internal read-only data of Unicode objects:
7091

Doc/library/array.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
--------------
1010

1111
This module defines an object type which can compactly represent an array of
12-
basic values: characters, integers, floating-point numbers. Arrays are sequence
12+
basic values: characters, integers, floating-point numbers. Arrays are mutable :term:`sequence`
1313
types and behave very much like lists, except that the type of objects stored in
1414
them is constrained. The type is specified at object creation time by using a
1515
:dfn:`type code`, which is a single character. The following type codes are
@@ -93,7 +93,7 @@ The module defines the following type:
9393
otherwise, the initializer's iterator is passed to the :meth:`extend` method
9494
to add initial items to the array.
9595

96-
Array objects support the ordinary sequence operations of indexing, slicing,
96+
Array objects support the ordinary :ref:`mutable <typesseq-mutable>` :term:`sequence` operations of indexing, slicing,
9797
concatenation, and multiplication. When using slice assignment, the assigned
9898
value must be an array object with the same type code; in all other cases,
9999
:exc:`TypeError` is raised. Array objects also implement the buffer interface,

Doc/library/enum.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ Module Contents
153153

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

156+
:func:`enum.bin`
157+
158+
Like built-in :func:`bin`, except negative values are represented in
159+
two's complement, and the leading bit always indicates sign
160+
(``0`` implies positive, ``1`` implies negative).
161+
156162

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

10361042
.. versionadded:: 3.11
10371043

1044+
.. function:: bin(num, max_bits=None)
1045+
1046+
Like built-in :func:`bin`, except negative values are represented in
1047+
two's complement, and the leading bit always indicates sign
1048+
(``0`` implies positive, ``1`` implies negative).
1049+
1050+
>>> import enum
1051+
>>> enum.bin(10)
1052+
'0b0 1010'
1053+
>>> enum.bin(~10) # ~10 is -11
1054+
'0b1 0101'
1055+
1056+
.. versionadded:: 3.10
1057+
10381058
---------------
10391059

10401060
Notes

Doc/library/functions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ are always available. They are listed here in alphabetical order.
138138
>>> f'{14:#b}', f'{14:b}'
139139
('0b1110', '1110')
140140

141+
See also :func:`enum.bin` to represent negative values as twos-complement.
142+
141143
See also :func:`format` for more information.
142144

143145

Doc/library/pathlib.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,10 @@ Reading directories
13311331
PosixPath('setup.py'),
13321332
PosixPath('test_pathlib.py')]
13331333

1334+
.. note::
1335+
The paths are returned in no particular order.
1336+
If you need a specific order, sort the results.
1337+
13341338
.. seealso::
13351339
:ref:`pathlib-pattern-language` documentation.
13361340

@@ -1365,6 +1369,10 @@ Reading directories
13651369
Glob the given relative *pattern* recursively. This is like calling
13661370
:func:`Path.glob` with "``**/``" added in front of the *pattern*.
13671371

1372+
.. note::
1373+
The paths are returned in no particular order.
1374+
If you need a specific order, sort the results.
1375+
13681376
.. seealso::
13691377
:ref:`pathlib-pattern-language` and :meth:`Path.glob` documentation.
13701378

Doc/library/stdtypes.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,11 +1093,14 @@ Notes:
10931093
still ``0``.
10941094

10951095
(4)
1096-
The slice of *s* from *i* to *j* is defined as the sequence of items with index
1097-
*k* such that ``i <= k < j``. If *i* or *j* is greater than ``len(s)``, use
1098-
``len(s)``. If *i* is omitted or ``None``, use ``0``. If *j* is omitted or
1099-
``None``, use ``len(s)``. If *i* is greater than or equal to *j*, the slice is
1100-
empty.
1096+
The slice of *s* from *i* to *j* is defined as the sequence of items with
1097+
index *k* such that ``i <= k < j``.
1098+
1099+
* If *i* is omitted or ``None``, use ``0``.
1100+
* If *j* is omitted or ``None``, use ``len(s)``.
1101+
* If *i* or *j* is less than ``-len(s)``, use ``0``.
1102+
* If *i* or *j* is greater than ``len(s)``, use ``len(s)``.
1103+
* If *i* is greater than or equal to *j*, the slice is empty.
11011104

11021105
(5)
11031106
The slice of *s* from *i* to *j* with step *k* is defined as the sequence of

Doc/library/typing.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,7 +2369,7 @@ These functions and classes should not be used directly as annotations.
23692369
Their intended purpose is to be building blocks for creating and declaring
23702370
types.
23712371

2372-
.. class:: NamedTuple
2372+
.. function:: NamedTuple
23732373

23742374
Typed version of :func:`collections.namedtuple`.
23752375

@@ -2442,6 +2442,10 @@ types.
24422442
Removed the ``_field_types`` attribute in favor of the more
24432443
standard ``__annotations__`` attribute which has the same information.
24442444

2445+
.. versionchanged:: 3.9
2446+
``NamedTuple`` is now a function rather than a class.
2447+
It can still be used as a class base, as described above.
2448+
24452449
.. versionchanged:: 3.11
24462450
Added support for generic namedtuples.
24472451

@@ -2585,10 +2589,10 @@ types.
25852589
for more details.
25862590

25872591

2588-
.. class:: TypedDict(dict)
2592+
.. function:: TypedDict
25892593

25902594
Special construct to add type hints to a dictionary.
2591-
At runtime it is a plain :class:`dict`.
2595+
At runtime ":class:`!TypedDict` instances" are simply :class:`dicts <dict>`.
25922596

25932597
``TypedDict`` declares a dictionary type that expects all of its
25942598
instances to have a certain set of keys, where each key is
@@ -2811,6 +2815,10 @@ types.
28112815

28122816
.. versionadded:: 3.8
28132817

2818+
.. versionchanged:: 3.9
2819+
``TypedDict`` is now a function rather than a class.
2820+
It can still be used as a class base, as described above.
2821+
28142822
.. versionchanged:: 3.11
28152823
Added support for marking individual keys as :data:`Required` or :data:`NotRequired`.
28162824
See :pep:`655`.

Doc/reference/datamodel.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,12 @@ Slice objects are used to represent slices for
18191819
:meth:`~object.__getitem__`
18201820
methods. They are also created by the built-in :func:`slice` function.
18211821

1822+
.. versionadded:: 3.15
1823+
1824+
The :func:`slice` type now supports :ref:`subscription <subscriptions>`. For
1825+
example, ``slice[float]`` may be used in type annotations to indicate a slice
1826+
containing :type:`float` objects.
1827+
18221828
.. index::
18231829
single: start (slice object attribute)
18241830
single: stop (slice object attribute)

Doc/whatsnew/3.15.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ Other language changes
402402
:class:`tuple` (including classes created by :func:`collections.namedtuple`).
403403
(Contributed by Serhiy Storchaka in :gh:`41779`.)
404404

405+
* The :class:`slice` type now supports subscription,
406+
making it a :term:`generic type`.
407+
(Contributed by James Hilton-Balfe in :gh:`128335`.)
405408

406409
New modules
407410
===========
@@ -889,14 +892,14 @@ Upgraded JIT compiler
889892

890893
Results from the `pyperformance <https://github.com/python/pyperformance>`__
891894
benchmark suite report
892-
`3-4% <https://github.com/facebookexperimental/free-threading-benchmarking/blob/main/results/bm-20251214-3.15.0a2%2B-6cddf04-JIT/bm-20251214-vultr-x86_64-python-6cddf04344a1e8ca9df5-3.15.0a2%2B-6cddf04-vs-base.svg>`__
895+
`4-5% <https://raw.githubusercontent.com/facebookexperimental/free-threading-benchmarking/refs/heads/main/results/bm-20260110-3.15.0a3%2B-aa8578d-JIT/bm-20260110-vultr-x86_64-python-aa8578dc54df2af9daa3-3.15.0a3%2B-aa8578d-vs-base.svg>`__
893896
geometric mean performance improvement for the JIT over the standard CPython
894897
interpreter built with all optimizations enabled on x86-64 Linux. On AArch64
895898
macOS, the JIT has a
896-
`7-8% <https://raw.githubusercontent.com/facebookexperimental/free-threading-benchmarking/refs/heads/main/results/bm-20260103-3.15.0a3%2B-9609574-JIT/bm-20260103-macm4pro-arm64-python-9609574e7fd36edfaa8b-3.15.0a3%2B-9609574-vs-base.svg>`__
899+
`7-8% <https://raw.githubusercontent.com/facebookexperimental/free-threading-benchmarking/refs/heads/main/results/bm-20260110-3.15.0a3%2B-aa8578d-JIT/bm-20260110-macm4pro-arm64-python-aa8578dc54df2af9daa3-3.15.0a3%2B-aa8578d-vs-base.svg>`__
897900
speedup over the :ref:`tail calling interpreter <whatsnew314-tail-call-interpreter>`
898901
with all optimizations enabled. The speedups for JIT
899-
builds versus no JIT builds range from roughly 20% slowdown to over
902+
builds versus no JIT builds range from roughly 15% slowdown to over
900903
100% speedup (ignoring the ``unpack_sequence`` microbenchmark) on
901904
x86-64 Linux and AArch64 macOS systems.
902905

0 commit comments

Comments
 (0)