Skip to content

Commit b7d7225

Browse files
gh-136669: build _asyncio as static module (#136670)
`_asyncio` is now built as a static module so that thread states can be accessed directly via registers and avoids the overhead of function call.
1 parent 69d8fe5 commit b7d7225

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:mod:`!_asyncio` is now statically linked for improved performance.

Modules/Setup.stdlib.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
############################################################################
3333
# Modules that should always be present (POSIX and Windows):
3434
@MODULE_ARRAY_TRUE@array arraymodule.c
35-
@MODULE__ASYNCIO_TRUE@_asyncio _asynciomodule.c
3635
@MODULE__BISECT_TRUE@_bisect _bisectmodule.c
3736
@MODULE__CSV_TRUE@_csv _csv.c
3837
@MODULE__HEAPQ_TRUE@_heapq _heapqmodule.c
@@ -193,3 +192,9 @@
193192
# Limited API template modules; must be built as shared modules.
194193
@MODULE_XXLIMITED_TRUE@xxlimited xxlimited.c
195194
@MODULE_XXLIMITED_35_TRUE@xxlimited_35 xxlimited_35.c
195+
196+
197+
# for performance
198+
*static*
199+
200+
@MODULE__ASYNCIO_TRUE@_asyncio _asynciomodule.c

Modules/_remote_debugging_module.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle)
811811
}
812812
#elif defined(__linux__)
813813
// On Linux, search for asyncio debug in executable or DLL
814-
address = search_linux_map_for_section(handle, "AsyncioDebug", "_asyncio.cpython");
814+
address = search_linux_map_for_section(handle, "AsyncioDebug", "python");
815815
if (address == 0) {
816816
// Error out: 'python' substring covers both executable and DLL
817817
PyObject *exc = PyErr_GetRaisedException();
@@ -820,10 +820,10 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle)
820820
}
821821
#elif defined(__APPLE__) && TARGET_OS_OSX
822822
// On macOS, try libpython first, then fall back to python
823-
address = search_map_for_section(handle, "AsyncioDebug", "_asyncio.cpython");
823+
address = search_map_for_section(handle, "AsyncioDebug", "libpython");
824824
if (address == 0) {
825825
PyErr_Clear();
826-
address = search_map_for_section(handle, "AsyncioDebug", "_asyncio.cpython");
826+
address = search_map_for_section(handle, "AsyncioDebug", "python");
827827
}
828828
if (address == 0) {
829829
// Error out: 'python' substring covers both executable and DLL

0 commit comments

Comments
 (0)