https://github.com/python/cpython/commit/24e643d4ef024a3561c927dc07c59c435bb27bcc
commit: 24e643d4ef024a3561c927dc07c59c435bb27bcc
branch: main
author: Sam Gross <[email protected]>
committer: colesbury <[email protected]>
date: 2024-05-03T11:05:30-04:00
summary:

gh-118527: Use `_Py_ID(__main__)` for main module name (#118528)

Most module names are interned and immortalized, but the main
module was not. This partially addresses a scaling bottleneck in the
free-threaded when creating closure concurrently in the main module.

files:
M Python/pylifecycle.c

diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 7726ccc979dbcc..9dc6e3f31128c1 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -2348,7 +2348,7 @@ static PyStatus
 add_main_module(PyInterpreterState *interp)
 {
     PyObject *m, *d, *ann_dict;
-    m = PyImport_AddModule("__main__");
+    m = PyImport_AddModuleObject(&_Py_ID(__main__));
     if (m == NULL)
         return _PyStatus_ERR("can't create __main__ module");
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to