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.
This commit is contained in:
Sam Gross 2024-05-03 11:05:30 -04:00 committed by GitHub
parent c8deb1e4b4
commit 24e643d4ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View 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");