From 48a8c84f7c6fee8a595ccea51159958bff76fc3c Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Tue, 15 Jul 2025 13:22:10 +0530 Subject: [PATCH 1/6] build _asyncio as static module --- Modules/Setup.bootstrap.in | 2 ++ Modules/Setup.stdlib.in | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in index 2b2e8cb3e3cacd..8d7dbf6514dc1f 100644 --- a/Modules/Setup.bootstrap.in +++ b/Modules/Setup.bootstrap.in @@ -38,3 +38,5 @@ _symtable symtablemodule.c # for systems without $HOME env, used by site._getuserbase() @MODULE_PWD_TRUE@pwd pwdmodule.c + +@MODULE__ASYNCIO_TRUE@_asyncio _asynciomodule.c diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index 3a38a60a152e8c..2c59eccd8015ff 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -32,7 +32,6 @@ ############################################################################ # Modules that should always be present (POSIX and Windows): @MODULE_ARRAY_TRUE@array arraymodule.c -@MODULE__ASYNCIO_TRUE@_asyncio _asynciomodule.c @MODULE__BISECT_TRUE@_bisect _bisectmodule.c @MODULE__CSV_TRUE@_csv _csv.c @MODULE__HEAPQ_TRUE@_heapq _heapqmodule.c From cca01ffb12addad0ed5e328c86ce87805f1ea6f1 Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Tue, 15 Jul 2025 17:10:12 +0530 Subject: [PATCH 2/6] use stdlib.in --- Modules/Setup.bootstrap.in | 1 - Modules/Setup.stdlib.in | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in index 8d7dbf6514dc1f..e811790bf29325 100644 --- a/Modules/Setup.bootstrap.in +++ b/Modules/Setup.bootstrap.in @@ -39,4 +39,3 @@ _symtable symtablemodule.c # for systems without $HOME env, used by site._getuserbase() @MODULE_PWD_TRUE@pwd pwdmodule.c -@MODULE__ASYNCIO_TRUE@_asyncio _asynciomodule.c diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index 2c59eccd8015ff..86c8eb27c0a6c7 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -192,3 +192,9 @@ # Limited API template modules; must be built as shared modules. @MODULE_XXLIMITED_TRUE@xxlimited xxlimited.c @MODULE_XXLIMITED_35_TRUE@xxlimited_35 xxlimited_35.c + + +# for performance +*static* + +@MODULE__ASYNCIO_TRUE@_asyncio _asynciomodule.c From a7806d775b35677552e2e369c1d42ac3068e6ca5 Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Tue, 15 Jul 2025 17:10:56 +0530 Subject: [PATCH 3/6] fmt --- Modules/Setup.bootstrap.in | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in index e811790bf29325..2b2e8cb3e3cacd 100644 --- a/Modules/Setup.bootstrap.in +++ b/Modules/Setup.bootstrap.in @@ -38,4 +38,3 @@ _symtable symtablemodule.c # for systems without $HOME env, used by site._getuserbase() @MODULE_PWD_TRUE@pwd pwdmodule.c - From c84e757cd6c07edc477e00948e5e0916de2c24d9 Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Tue, 15 Jul 2025 17:24:03 +0530 Subject: [PATCH 4/6] fix external introspection --- Modules/_remote_debugging_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_remote_debugging_module.c b/Modules/_remote_debugging_module.c index d72031137e0a4e..da2298ca7369a9 100644 --- a/Modules/_remote_debugging_module.c +++ b/Modules/_remote_debugging_module.c @@ -811,7 +811,7 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle) } #elif defined(__linux__) // On Linux, search for asyncio debug in executable or DLL - address = search_linux_map_for_section(handle, "AsyncioDebug", "_asyncio.cpython"); + address = search_linux_map_for_section(handle, "AsyncioDebug", "python"); if (address == 0) { // Error out: 'python' substring covers both executable and DLL PyObject *exc = PyErr_GetRaisedException(); From 87ff8fc4b4396c251f1c940a4fa6bda67af34881 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 16:37:39 +0000 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2025-07-15-16-37-34.gh-issue-136669.Yexwah.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2025-07-15-16-37-34.gh-issue-136669.Yexwah.rst diff --git a/Misc/NEWS.d/next/Library/2025-07-15-16-37-34.gh-issue-136669.Yexwah.rst b/Misc/NEWS.d/next/Library/2025-07-15-16-37-34.gh-issue-136669.Yexwah.rst new file mode 100644 index 00000000000000..0d93397ff35d0b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-07-15-16-37-34.gh-issue-136669.Yexwah.rst @@ -0,0 +1 @@ +:mod:`!_asyncio` is now statically linked for improved performance. From 58eece0778ed8b20dbbc5c592f81956d1fa61d1c Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Wed, 16 Jul 2025 16:02:06 +0530 Subject: [PATCH 6/6] fix for macOS --- Modules/_remote_debugging_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/_remote_debugging_module.c b/Modules/_remote_debugging_module.c index da2298ca7369a9..b50e5e403a1a19 100644 --- a/Modules/_remote_debugging_module.c +++ b/Modules/_remote_debugging_module.c @@ -820,10 +820,10 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle) } #elif defined(__APPLE__) && TARGET_OS_OSX // On macOS, try libpython first, then fall back to python - address = search_map_for_section(handle, "AsyncioDebug", "_asyncio.cpython"); + address = search_map_for_section(handle, "AsyncioDebug", "libpython"); if (address == 0) { PyErr_Clear(); - address = search_map_for_section(handle, "AsyncioDebug", "_asyncio.cpython"); + address = search_map_for_section(handle, "AsyncioDebug", "python"); } if (address == 0) { // Error out: 'python' substring covers both executable and DLL