Skip to content

Commit 7697c11

Browse files
Merge branch 'main' into interp-pool-executor-use-interp-call
2 parents 202c790 + 3f9eb55 commit 7697c11

Some content is hidden

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

52 files changed

+1448
-815
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"image": "ghcr.io/python/devcontainer:2024.09.25.11038928730",
2+
"image": "ghcr.io/python/devcontainer:2025.05.25.15232270922",
33
"onCreateCommand": [
44
// Install common tooling.
55
"dnf",

Doc/c-api/intro.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,3 +838,41 @@ after every statement run by the interpreter.)
838838

839839
Please refer to :file:`Misc/SpecialBuilds.txt` in the Python source distribution
840840
for more detailed information.
841+
842+
843+
.. _c-api-tools:
844+
845+
Recommended third party tools
846+
=============================
847+
848+
The following third party tools offer both simpler and more sophisticated
849+
approaches to creating C, C++ and Rust extensions for Python:
850+
851+
* `Cython <https://cython.org/>`_
852+
* `cffi <https://cffi.readthedocs.io>`_
853+
* `HPy <https://hpyproject.org/>`_
854+
* `nanobind <https://github.com/wjakob/nanobind>`_ (C++)
855+
* `Numba <https://numba.pydata.org/>`_
856+
* `pybind11 <https://pybind11.readthedocs.io/>`_ (C++)
857+
* `PyO3 <https://pyo3.rs/>`_ (Rust)
858+
* `SWIG <https://www.swig.org>`_
859+
860+
Using tools such as these can help avoid writing code that is tightly bound to
861+
a particular version of CPython, avoid reference counting errors, and focus
862+
more on your own code than on using the CPython API. In general, new versions
863+
of Python can be supported by updating the tool, and your code will often use
864+
newer and more efficient APIs automatically. Some tools also support compiling
865+
for other implementations of Python from a single set of sources.
866+
867+
These projects are not supported by the same people who maintain Python, and
868+
issues need to be raised with the projects directly. Remember to check that the
869+
project is still maintained and supported, as the list above may become
870+
outdated.
871+
872+
.. seealso::
873+
874+
`Python Packaging User Guide: Binary Extensions <https://packaging.python.org/guides/packaging-binary-extensions/>`_
875+
The Python Packaging User Guide not only covers several available
876+
tools that simplify the creation of binary extensions, but also
877+
discusses the various reasons why creating an extension module may be
878+
desirable in the first place.

Doc/extending/index.rst

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,9 @@ Recommended third party tools
2626
=============================
2727

2828
This guide only covers the basic tools for creating extensions provided
29-
as part of this version of CPython. Third party tools like
30-
`Cython <https://cython.org/>`_, `cffi <https://cffi.readthedocs.io>`_,
31-
`SWIG <https://www.swig.org>`_ and `Numba <https://numba.pydata.org/>`_
32-
offer both simpler and more sophisticated approaches to creating C and C++
33-
extensions for Python.
34-
35-
.. seealso::
36-
37-
`Python Packaging User Guide: Binary Extensions <https://packaging.python.org/guides/packaging-binary-extensions/>`_
38-
The Python Packaging User Guide not only covers several available
39-
tools that simplify the creation of binary extensions, but also
40-
discusses the various reasons why creating an extension module may be
41-
desirable in the first place.
29+
as part of this version of CPython. Some :ref:`third party tools
30+
<c-api-tools>` offer both simpler and more sophisticated approaches to creating
31+
C and C++ extensions for Python.
4232

4333

4434
Creating extensions without third party tools

Doc/faq/extending.rst

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,9 @@ Writing C is hard; are there any alternatives?
3737
----------------------------------------------
3838

3939
There are a number of alternatives to writing your own C extensions, depending
40-
on what you're trying to do.
41-
42-
.. XXX make sure these all work
43-
44-
`Cython <https://cython.org>`_ and its relative `Pyrex
45-
<https://www.csse.canterbury.ac.nz/greg.ewing/python/Pyrex/>`_ are compilers
46-
that accept a slightly modified form of Python and generate the corresponding
47-
C code. Cython and Pyrex make it possible to write an extension without having
48-
to learn Python's C API.
49-
50-
If you need to interface to some C or C++ library for which no Python extension
51-
currently exists, you can try wrapping the library's data types and functions
52-
with a tool such as `SWIG <https://www.swig.org>`_. `SIP
53-
<https://github.com/Python-SIP/sip>`__, `CXX
54-
<https://cxx.sourceforge.net/>`_ `Boost
55-
<https://www.boost.org/libs/python/doc/index.html>`_, or `Weave
56-
<https://github.com/scipy/weave>`_ are also
57-
alternatives for wrapping C++ libraries.
40+
on what you're trying to do. :ref:`Recommended third party tools <c-api-tools>`
41+
offer both simpler and more sophisticated approaches to creating C and C++
42+
extensions for Python.
5843

5944

6045
How can I execute arbitrary Python statements from C?

Doc/howto/cporting.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ We recommend the following resources for porting extension modules to Python 3:
1414
module.
1515
* The `Porting guide`_ from the *py3c* project provides opinionated
1616
suggestions with supporting code.
17-
* The `Cython`_ and `CFFI`_ libraries offer abstractions over
18-
Python's C API.
17+
* :ref:`Recommended third party tools <c-api-tools>` offer abstractions over
18+
the Python's C API.
1919
Extensions generally need to be re-written to use one of them,
2020
but the library then handles differences between various Python
2121
versions and implementations.
2222

2323
.. _Migrating C extensions: http://python3porting.com/cextensions.html
2424
.. _Porting guide: https://py3c.readthedocs.io/en/latest/guide.html
25-
.. _Cython: https://cython.org/
26-
.. _CFFI: https://cffi.readthedocs.io/en/latest/

Doc/howto/curses.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ your terminal won't be left in a funny state on exception and you'll be
161161
able to read the exception's message and traceback.
162162

163163

164+
.. _windows-and-pads:
165+
164166
Windows and Pads
165167
================
166168

Doc/library/asyncio-stream.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,17 @@ and work with streams:
171171
.. function:: start_unix_server(client_connected_cb, path=None, \
172172
*, limit=None, sock=None, backlog=100, ssl=None, \
173173
ssl_handshake_timeout=None, \
174-
ssl_shutdown_timeout=None, start_serving=True)
174+
ssl_shutdown_timeout=None, start_serving=True, cleanup_socket=True)
175175
:async:
176176
177177
Start a Unix socket server.
178178

179179
Similar to :func:`start_server` but works with Unix sockets.
180180

181+
If *cleanup_socket* is true then the Unix socket will automatically
182+
be removed from the filesystem when the server is closed, unless the
183+
socket has been replaced after the server has been created.
184+
181185
See also the documentation of :meth:`loop.create_unix_server`.
182186

183187
.. note::
@@ -198,6 +202,9 @@ and work with streams:
198202
.. versionchanged:: 3.11
199203
Added the *ssl_shutdown_timeout* parameter.
200204

205+
.. versionchanged:: 3.13
206+
Added the *cleanup_socket* parameter.
207+
201208

202209
StreamReader
203210
============

Doc/library/zlib.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ The available exception and functions in this module are:
4444
.. versionchanged:: 3.0
4545
The result is always unsigned.
4646

47+
.. function:: adler32_combine(adler1, adler2, len2, /)
48+
49+
Combine two Adler-32 checksums into one.
50+
51+
Given the Adler-32 checksum *adler1* of a sequence ``A`` and the
52+
Adler-32 checksum *adler2* of a sequence ``B`` of length *len2*,
53+
return the Adler-32 checksum of ``A`` and ``B`` concatenated.
54+
55+
This function is typically useful to combine Adler-32 checksums
56+
that were concurrently computed. To compute checksums sequentially, use
57+
:func:`adler32` with the running checksum as the ``value`` argument.
58+
59+
.. versionadded:: next
60+
4761
.. function:: compress(data, /, level=-1, wbits=MAX_WBITS)
4862

4963
Compresses the bytes in *data*, returning a bytes object containing compressed data.
@@ -136,6 +150,20 @@ The available exception and functions in this module are:
136150
.. versionchanged:: 3.0
137151
The result is always unsigned.
138152

153+
.. function:: crc32_combine(crc1, crc2, len2, /)
154+
155+
Combine two CRC-32 checksums into one.
156+
157+
Given the CRC-32 checksum *crc1* of a sequence ``A`` and the
158+
CRC-32 checksum *crc2* of a sequence ``B`` of length *len2*,
159+
return the CRC-32 checksum of ``A`` and ``B`` concatenated.
160+
161+
This function is typically useful to combine CRC-32 checksums
162+
that were concurrently computed. To compute checksums sequentially, use
163+
:func:`crc32` with the running checksum as the ``value`` argument.
164+
165+
.. versionadded:: next
166+
139167
.. function:: decompress(data, /, wbits=MAX_WBITS, bufsize=DEF_BUF_SIZE)
140168

141169
Decompresses the bytes in *data*, returning a bytes object containing the

Doc/whatsnew/3.15.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ ssl
9797
(Contributed by Will Childs-Klein in :gh:`133624`.)
9898

9999

100+
zlib
101+
----
102+
103+
* Allow combining two Adler-32 checksums via :func:`~zlib.adler32_combine`.
104+
(Contributed by Callum Attryde and Bénédikt Tran in :gh:`134635`.)
105+
106+
* Allow combining two CRC-32 checksums via :func:`~zlib.crc32_combine`.
107+
(Contributed by Bénédikt Tran in :gh:`134635`.)
108+
109+
100110
.. Add improved modules above alphabetically, not here at the end.
101111
102112
Optimizations

Include/internal/pycore_ceval.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ PyAPI_FUNC(_PyStackRef) _PyFloat_FromDouble_ConsumeInputs(_PyStackRef left, _PyS
353353
extern int _PyRunRemoteDebugger(PyThreadState *tstate);
354354
#endif
355355

356+
_PyStackRef _PyForIter_NextWithIndex(PyObject *seq, _PyStackRef index);
357+
356358
#ifdef __cplusplus
357359
}
358360
#endif

Include/internal/pycore_code.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ extern void _Py_Specialize_CompareOp(_PyStackRef lhs, _PyStackRef rhs,
313313
_Py_CODEUNIT *instr, int oparg);
314314
extern void _Py_Specialize_UnpackSequence(_PyStackRef seq, _Py_CODEUNIT *instr,
315315
int oparg);
316-
extern void _Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int oparg);
316+
extern void _Py_Specialize_ForIter(_PyStackRef iter, _PyStackRef null_or_index, _Py_CODEUNIT *instr, int oparg);
317317
extern void _Py_Specialize_Send(_PyStackRef receiver, _Py_CODEUNIT *instr);
318318
extern void _Py_Specialize_ToBool(_PyStackRef value, _Py_CODEUNIT *instr);
319319
extern void _Py_Specialize_ContainsOp(_PyStackRef value, _Py_CODEUNIT *instr);

Include/internal/pycore_compile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ typedef enum {
9595
enum _PyCompile_FBlockType {
9696
COMPILE_FBLOCK_WHILE_LOOP,
9797
COMPILE_FBLOCK_FOR_LOOP,
98+
COMPILE_FBLOCK_ASYNC_FOR_LOOP,
9899
COMPILE_FBLOCK_TRY_EXCEPT,
99100
COMPILE_FBLOCK_FINALLY_TRY,
100101
COMPILE_FBLOCK_FINALLY_END,

Include/internal/pycore_magic_number.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ Known values:
279279
Python 3.14b1 3624 (Don't optimize LOAD_FAST when local is killed by DELETE_FAST)
280280
Python 3.15a0 3650 (Initial version)
281281
Python 3.15a1 3651 (Simplify LOAD_CONST)
282+
Python 3.15a1 3652 (Virtual iterators)
283+
282284
283285
Python 3.16 will start with 3700
284286
@@ -291,7 +293,7 @@ PC/launcher.c must also be updated.
291293
292294
*/
293295

294-
#define PYC_MAGIC_NUMBER 3651
296+
#define PYC_MAGIC_NUMBER 3652
295297
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
296298
(little-endian) and then appending b'\r\n'. */
297299
#define PYC_MAGIC_NUMBER_TOKEN \

Include/internal/pycore_opcode_metadata.h

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

0 commit comments

Comments
 (0)