]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-118527: Use `_Py_ID(__main__)` for main module name (#118528)
authorSam Gross <colesbury@gmail.com>
Fri, 3 May 2024 15:05:30 +0000 (11:05 -0400)
committerGitHub <noreply@github.com>
Fri, 3 May 2024 15:05:30 +0000 (11:05 -0400)
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.

Python/pylifecycle.c

index 7726ccc979dbcc093a97fd95db1d13eafd1e2884..9dc6e3f31128c1baa5dcb51a90078c15b1ea2e3f 100644 (file)
@@ -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");