Skip to content

Commit 1dd060c

Browse files
Merge branch 'main' into shrink-stencils
2 parents 1914f2e + c0c6514 commit 1dd060c

File tree

116 files changed

+9335
-3707
lines changed

Some content is hidden

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

116 files changed

+9335
-3707
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ contact_links:
55
- name: "Proposing new features"
66
about: "Submit major feature proposal (e.g. syntax changes) to an ideas forum first."
77
url: "https://discuss.python.org/c/ideas/6"
8+
- name: "Python Install Manager issues"
9+
about: "Report issues with the Python Install Manager (for Windows)"
10+
url: "https://github.com/python/pymanager/issues"

Doc/c-api/descriptor.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,46 @@ found in the dictionary of type objects.
2121
.. c:function:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth)
2222
2323
24+
.. c:var:: PyTypeObject PyMemberDescr_Type
25+
26+
The type object for member descriptor objects created from
27+
:c:type:`PyMemberDef` structures. These descriptors expose fields of a
28+
C struct as attributes on a type, and correspond
29+
to :class:`types.MemberDescriptorType` objects in Python.
30+
31+
32+
33+
.. c:var:: PyTypeObject PyGetSetDescr_Type
34+
35+
The type object for get/set descriptor objects created from
36+
:c:type:`PyGetSetDef` structures. These descriptors implement attributes
37+
whose value is computed by C getter and setter functions, and are used
38+
for many built-in type attributes.
39+
40+
2441
.. c:function:: PyObject* PyDescr_NewMethod(PyTypeObject *type, struct PyMethodDef *meth)
2542
2643
44+
.. c:var:: PyTypeObject PyMethodDescr_Type
45+
46+
The type object for method descriptor objects created from
47+
:c:type:`PyMethodDef` structures. These descriptors expose C functions as
48+
methods on a type, and correspond to :class:`types.MemberDescriptorType`
49+
objects in Python.
50+
51+
2752
.. c:function:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *wrapper, void *wrapped)
2853
2954
55+
.. c:var:: PyTypeObject PyWrapperDescr_Type
56+
57+
The type object for wrapper descriptor objects created by
58+
:c:func:`PyDescr_NewWrapper` and :c:func:`PyWrapper_New`. Wrapper
59+
descriptors are used internally to expose special methods implemented
60+
via wrapper structures, and appear in Python as
61+
:class:`types.WrapperDescriptorType` objects.
62+
63+
3064
.. c:function:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
3165
3266
@@ -55,6 +89,14 @@ Built-in descriptors
5589
:class:`classmethod` in the Python layer.
5690
5791
92+
.. c:var:: PyTypeObject PyClassMethodDescr_Type
93+
94+
The type object for C-level class method descriptor objects.
95+
This is the type of the descriptors created for :func:`classmethod` defined in
96+
C extension types, and is the same object as :class:`classmethod`
97+
in Python.
98+
99+
58100
.. c:function:: PyObject *PyClassMethod_New(PyObject *callable)
59101
60102
Create a new :class:`classmethod` object wrapping *callable*.

Doc/c-api/dict.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ Dictionary Objects
4343
prevent modification of the dictionary for non-dynamic class types.
4444
4545
46+
.. c:var:: PyTypeObject PyDictProxy_Type
47+
48+
The type object for mapping proxy objects created by
49+
:c:func:`PyDictProxy_New` and for the read-only ``__dict__`` attribute
50+
of many built-in types. A :c:type:`PyDictProxy_Type` instance provides a
51+
dynamic, read-only view of an underlying dictionary: changes to the
52+
underlying dictionary are reflected in the proxy, but the proxy itself
53+
does not support mutation operations. This corresponds to
54+
:class:`types.MappingProxyType` in Python.
55+
56+
4657
.. c:function:: void PyDict_Clear(PyObject *p)
4758
4859
Empty an existing dictionary of all key-value pairs.

Doc/howto/free-threading-python.rst

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ available processing power by running threads in parallel on available CPU cores
1111
While not all software will benefit from this automatically, programs
1212
designed with threading in mind will run faster on multi-core hardware.
1313

14-
The free-threaded mode is working and continues to be improved, but
15-
there is some additional overhead in single-threaded workloads compared
16-
to the regular build. Additionally, third-party packages, in particular ones
14+
Some third-party packages, in particular ones
1715
with an :term:`extension module`, may not be ready for use in a
1816
free-threaded build, and will re-enable the :term:`GIL`.
1917

@@ -101,63 +99,42 @@ This section describes known limitations of the free-threaded CPython build.
10199
Immortalization
102100
---------------
103101

104-
The free-threaded build of the 3.13 release makes some objects :term:`immortal`.
102+
In the free-threaded build, some objects are :term:`immortal`.
105103
Immortal objects are not deallocated and have reference counts that are
106104
never modified. This is done to avoid reference count contention that would
107105
prevent efficient multi-threaded scaling.
108106

109-
An object will be made immortal when a new thread is started for the first time
110-
after the main thread is running. The following objects are immortalized:
107+
As of the 3.14 release, immortalization is limited to:
111108

112-
* :ref:`function <user-defined-funcs>` objects declared at the module level
113-
* :ref:`method <instance-methods>` descriptors
114-
* :ref:`code <code-objects>` objects
115-
* :term:`module` objects and their dictionaries
116-
* :ref:`classes <classes>` (type objects)
117-
118-
Because immortal objects are never deallocated, applications that create many
119-
objects of these types may see increased memory usage under Python 3.13. This
120-
has been addressed in the 3.14 release, where the aforementioned objects use
121-
deferred reference counting to avoid reference count contention.
122-
123-
Additionally, numeric and string literals in the code as well as strings
124-
returned by :func:`sys.intern` are also immortalized in the 3.13 release. This
125-
behavior is part of the 3.14 release as well and it is expected to remain in
126-
future free-threaded builds.
109+
* Code constants: numeric literals, string literals, and tuple literals
110+
composed of other constants.
111+
* Strings interned by :func:`sys.intern`.
127112

128113

129114
Frame objects
130115
-------------
131116

132-
It is not safe to access :ref:`frame <frame-objects>` objects from other
133-
threads and doing so may cause your program to crash . This means that
134-
:func:`sys._current_frames` is generally not safe to use in a free-threaded
135-
build. Functions like :func:`inspect.currentframe` and :func:`sys._getframe`
136-
are generally safe as long as the resulting frame object is not passed to
137-
another thread.
117+
It is not safe to access :attr:`frame.f_locals` from a :ref:`frame <frame-objects>`
118+
object if that frame is currently executing in another thread, and doing so may
119+
crash the interpreter.
120+
138121

139122
Iterators
140123
---------
141124

142-
Sharing the same iterator object between multiple threads is generally not
143-
safe and threads may see duplicate or missing elements when iterating or crash
144-
the interpreter.
125+
It is generally not thread-safe to access the same iterator object from
126+
multiple threads concurrently, and threads may see duplicate or missing
127+
elements.
145128

146129

147130
Single-threaded performance
148131
---------------------------
149132

150133
The free-threaded build has additional overhead when executing Python code
151-
compared to the default GIL-enabled build. In 3.13, this overhead is about
152-
40% on the `pyperformance <https://pyperformance.readthedocs.io/>`_ suite.
153-
Programs that spend most of their time in C extensions or I/O will see
154-
less of an impact. The largest impact is because the specializing adaptive
155-
interpreter (:pep:`659`) is disabled in the free-threaded build.
156-
157-
The specializing adaptive interpreter has been re-enabled in a thread-safe way
158-
in the 3.14 release. The performance penalty on single-threaded code in
159-
free-threaded mode is now roughly 5-10%, depending on the platform and C
160-
compiler used.
134+
compared to the default GIL-enabled build. The amount of overhead depends
135+
on the workload and hardware. On the pyperformance benchmark suite, the
136+
average overhead ranges from about 1% on macOS aarch64 to 8% on x86-64 Linux
137+
systems.
161138

162139

163140
Behavioral changes

Doc/howto/functional.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Functional Programming HOWTO
55
********************************
66

7-
:Author: A. M. Kuchling
7+
:Author: \A. M. Kuchling
88
:Release: 0.32
99

1010
In this document, we'll take a tour of Python's features suitable for

Doc/howto/urllib2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Introduction
1515
You may also find useful the following article on fetching web resources
1616
with Python:
1717

18-
* `Basic Authentication <https://web.archive.org/web/20201215133350/http://www.voidspace.org.uk/python/articles/authentication.shtml>`_
18+
* `Basic Authentication <https://web.archive.org/web/20201215133350/http://www.voidspace.org.uk/python/articles/authentication.shtml>`__
1919

2020
A tutorial on *Basic Authentication*, with examples in Python.
2121

Doc/library/argparse.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,9 @@ how the command-line arguments should be handled. The supplied actions are:
767767
Namespace(foo=42)
768768

769769
* ``'store_true'`` and ``'store_false'`` - These are special cases of
770-
``'store_const'`` used for storing the values ``True`` and ``False``
771-
respectively. In addition, they create default values of ``False`` and
772-
``True`` respectively::
770+
``'store_const'`` that respectively store the values ``True`` and ``False``
771+
with default values of ``False`` and
772+
``True``::
773773

774774
>>> parser = argparse.ArgumentParser()
775775
>>> parser.add_argument('--foo', action='store_true')
@@ -789,8 +789,8 @@ how the command-line arguments should be handled. The supplied actions are:
789789
>>> parser.parse_args('--foo 1 --foo 2'.split())
790790
Namespace(foo=['0', '1', '2'])
791791

792-
* ``'append_const'`` - This stores a list, and appends the value specified by
793-
the const_ keyword argument to the list; note that the const_ keyword
792+
* ``'append_const'`` - This appends the value specified by
793+
the const_ keyword argument to a list; note that the const_ keyword
794794
argument defaults to ``None``. The ``'append_const'`` action is typically
795795
useful when multiple arguments need to store constants to the same list. For
796796
example::
@@ -801,8 +801,8 @@ how the command-line arguments should be handled. The supplied actions are:
801801
>>> parser.parse_args('--str --int'.split())
802802
Namespace(types=[<class 'str'>, <class 'int'>])
803803

804-
* ``'extend'`` - This stores a list and appends each item from the multi-value
805-
argument list to it.
804+
* ``'extend'`` - This appends each item from a multi-value
805+
argument to a list.
806806
The ``'extend'`` action is typically used with the nargs_ keyword argument
807807
value ``'+'`` or ``'*'``.
808808
Note that when nargs_ is ``None`` (the default) or ``'?'``, each
@@ -816,7 +816,7 @@ how the command-line arguments should be handled. The supplied actions are:
816816

817817
.. versionadded:: 3.8
818818

819-
* ``'count'`` - This counts the number of times a keyword argument occurs. For
819+
* ``'count'`` - This counts the number of times an argument occurs. For
820820
example, this is useful for increasing verbosity levels::
821821

822822
>>> parser = argparse.ArgumentParser()

Doc/library/decimal.rst

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,20 +2109,20 @@ to work with the :class:`Decimal` class::
21092109
Decimal FAQ
21102110
-----------
21112111

2112-
Q. It is cumbersome to type ``decimal.Decimal('1234.5')``. Is there a way to
2112+
Q: It is cumbersome to type ``decimal.Decimal('1234.5')``. Is there a way to
21132113
minimize typing when using the interactive interpreter?
21142114

2115-
A. Some users abbreviate the constructor to just a single letter:
2115+
A: Some users abbreviate the constructor to just a single letter:
21162116

21172117
>>> D = decimal.Decimal
21182118
>>> D('1.23') + D('3.45')
21192119
Decimal('4.68')
21202120

2121-
Q. In a fixed-point application with two decimal places, some inputs have many
2121+
Q: In a fixed-point application with two decimal places, some inputs have many
21222122
places and need to be rounded. Others are not supposed to have excess digits
21232123
and need to be validated. What methods should be used?
21242124

2125-
A. The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal places. If
2125+
A: The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal places. If
21262126
the :const:`Inexact` trap is set, it is also useful for validation:
21272127

21282128
>>> TWOPLACES = Decimal(10) ** -2 # same as Decimal('0.01')
@@ -2140,10 +2140,10 @@ the :const:`Inexact` trap is set, it is also useful for validation:
21402140
...
21412141
Inexact: None
21422142

2143-
Q. Once I have valid two place inputs, how do I maintain that invariant
2143+
Q: Once I have valid two place inputs, how do I maintain that invariant
21442144
throughout an application?
21452145

2146-
A. Some operations like addition, subtraction, and multiplication by an integer
2146+
A: Some operations like addition, subtraction, and multiplication by an integer
21472147
will automatically preserve fixed point. Others operations, like division and
21482148
non-integer multiplication, will change the number of decimal places and need to
21492149
be followed-up with a :meth:`~Decimal.quantize` step:
@@ -2175,21 +2175,21 @@ to handle the :meth:`~Decimal.quantize` step:
21752175
>>> div(b, a)
21762176
Decimal('0.03')
21772177

2178-
Q. There are many ways to express the same value. The numbers ``200``,
2178+
Q: There are many ways to express the same value. The numbers ``200``,
21792179
``200.000``, ``2E2``, and ``.02E+4`` all have the same value at
21802180
various precisions. Is there a way to transform them to a single recognizable
21812181
canonical value?
21822182

2183-
A. The :meth:`~Decimal.normalize` method maps all equivalent values to a single
2183+
A: The :meth:`~Decimal.normalize` method maps all equivalent values to a single
21842184
representative:
21852185

21862186
>>> values = map(Decimal, '200 200.000 2E2 .02E+4'.split())
21872187
>>> [v.normalize() for v in values]
21882188
[Decimal('2E+2'), Decimal('2E+2'), Decimal('2E+2'), Decimal('2E+2')]
21892189

2190-
Q. When does rounding occur in a computation?
2190+
Q: When does rounding occur in a computation?
21912191

2192-
A. It occurs *after* the computation. The philosophy of the decimal
2192+
A: It occurs *after* the computation. The philosophy of the decimal
21932193
specification is that numbers are considered exact and are created
21942194
independent of the current context. They can even have greater
21952195
precision than current context. Computations process with those
@@ -2207,10 +2207,10 @@ applied to the *result* of the computation::
22072207
>>> pi + 0 - Decimal('0.00005'). # Intermediate values are rounded
22082208
Decimal('3.1416')
22092209

2210-
Q. Some decimal values always print with exponential notation. Is there a way
2210+
Q: Some decimal values always print with exponential notation. Is there a way
22112211
to get a non-exponential representation?
22122212

2213-
A. For some values, exponential notation is the only way to express the number
2213+
A: For some values, exponential notation is the only way to express the number
22142214
of significant places in the coefficient. For example, expressing
22152215
``5.0E+3`` as ``5000`` keeps the value constant but cannot show the
22162216
original's two-place significance.
@@ -2225,9 +2225,9 @@ value unchanged:
22252225
>>> remove_exponent(Decimal('5E+3'))
22262226
Decimal('5000')
22272227

2228-
Q. Is there a way to convert a regular float to a :class:`Decimal`?
2228+
Q: Is there a way to convert a regular float to a :class:`Decimal`?
22292229

2230-
A. Yes, any binary floating-point number can be exactly expressed as a
2230+
A: Yes, any binary floating-point number can be exactly expressed as a
22312231
Decimal though an exact conversion may take more precision than intuition would
22322232
suggest:
22332233

@@ -2236,19 +2236,19 @@ suggest:
22362236
>>> Decimal(math.pi)
22372237
Decimal('3.141592653589793115997963468544185161590576171875')
22382238

2239-
Q. Within a complex calculation, how can I make sure that I haven't gotten a
2239+
Q: Within a complex calculation, how can I make sure that I haven't gotten a
22402240
spurious result because of insufficient precision or rounding anomalies.
22412241

2242-
A. The decimal module makes it easy to test results. A best practice is to
2242+
A: The decimal module makes it easy to test results. A best practice is to
22432243
re-run calculations using greater precision and with various rounding modes.
22442244
Widely differing results indicate insufficient precision, rounding mode issues,
22452245
ill-conditioned inputs, or a numerically unstable algorithm.
22462246

2247-
Q. I noticed that context precision is applied to the results of operations but
2247+
Q: I noticed that context precision is applied to the results of operations but
22482248
not to the inputs. Is there anything to watch out for when mixing values of
22492249
different precisions?
22502250

2251-
A. Yes. The principle is that all values are considered to be exact and so is
2251+
A: Yes. The principle is that all values are considered to be exact and so is
22522252
the arithmetic on those values. Only the results are rounded. The advantage
22532253
for inputs is that "what you type is what you get". A disadvantage is that the
22542254
results can look odd if you forget that the inputs haven't been rounded:
@@ -2276,9 +2276,9 @@ Alternatively, inputs can be rounded upon creation using the
22762276
>>> Context(prec=5, rounding=ROUND_DOWN).create_decimal('1.2345678')
22772277
Decimal('1.2345')
22782278

2279-
Q. Is the CPython implementation fast for large numbers?
2279+
Q: Is the CPython implementation fast for large numbers?
22802280

2281-
A. Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of
2281+
A: Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of
22822282
the decimal module integrate the high speed `libmpdec
22832283
<https://www.bytereef.org/mpdecimal/doc/libmpdec/index.html>`_ library for
22842284
arbitrary precision correctly rounded decimal floating-point arithmetic [#]_.

0 commit comments

Comments
 (0)