Skip to content

Commit d1769ab

Browse files
committed
Merge branch 'main' of https://github.com/python/cpython into c-api-docs-check
2 parents 02d2f07 + c525204 commit d1769ab

File tree

99 files changed

+9093
-3636
lines changed

Some content is hidden

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

99 files changed

+9093
-3636
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/library/multiprocessing.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,8 @@ raising an exception.
832832

833833
One difference from other Python queue implementations, is that :mod:`multiprocessing`
834834
queues serializes all objects that are put into them using :mod:`pickle`.
835-
The object return by the get method is a re-created object that does not share memory
836-
with the original object.
835+
The object returned by the get method is a re-created object that does not share
836+
memory with the original object.
837837

838838
Note that one can also create a shared queue by using a manager object -- see
839839
:ref:`multiprocessing-managers`.
@@ -890,7 +890,7 @@ For an example of the usage of queues for interprocess communication see
890890
:ref:`multiprocessing-examples`.
891891

892892

893-
.. function:: Pipe([duplex])
893+
.. function:: Pipe(duplex=True)
894894

895895
Returns a pair ``(conn1, conn2)`` of
896896
:class:`~multiprocessing.connection.Connection` objects representing the
@@ -1577,12 +1577,22 @@ object -- see :ref:`multiprocessing-managers`.
15771577
A solitary difference from its close analog exists: its ``acquire`` method's
15781578
first argument is named *block*, as is consistent with :meth:`Lock.acquire`.
15791579

1580+
1581+
.. method:: get_value()
1582+
1583+
Return the current value of semaphore.
1584+
1585+
Note that this may raise :exc:`NotImplementedError` on platforms like
1586+
macOS where ``sem_getvalue()`` is not implemented.
1587+
1588+
15801589
.. method:: locked()
15811590

15821591
Return a boolean indicating whether this object is locked right now.
15831592

15841593
.. versionadded:: 3.14
15851594

1595+
15861596
.. note::
15871597

15881598
On macOS, ``sem_timedwait`` is unsupported, so calling ``acquire()`` with

Doc/library/select.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ The module defines the following:
115115
:ref:`kevent-objects` below for the methods supported by kevent objects.
116116

117117

118-
.. function:: select(rlist, wlist, xlist[, timeout])
118+
.. function:: select(rlist, wlist, xlist, timeout=None)
119119

120120
This is a straightforward interface to the Unix :c:func:`!select` system call.
121121
The first three arguments are iterables of 'waitable objects': either
@@ -131,7 +131,7 @@ The module defines the following:
131131
platform-dependent. (It is known to work on Unix but not on Windows.) The
132132
optional *timeout* argument specifies a time-out in seconds; it may be
133133
a non-integer to specify fractions of seconds.
134-
When the *timeout* argument is omitted the function blocks until
134+
When the *timeout* argument is omitted or ``None``, the function blocks until
135135
at least one file descriptor is ready. A time-out value of zero specifies a
136136
poll and never blocks.
137137

0 commit comments

Comments
 (0)