bpo-29585: optimize site.py startup time (GH-136)

Avoid importing `sysconfig` from `site` by copying minimum code.
Python startup is 5% faster on Linux and 30% faster on macOS
This commit is contained in:
INADA Naoki 2017-06-29 00:31:53 +09:00 committed by GitHub
parent 79d37ae979
commit a8f8d5b4bd
8 changed files with 96 additions and 43 deletions

View file

@ -1965,6 +1965,7 @@ _PySys_BeginInit(void)
SET_SYS_FROM_STRING("_git",
Py_BuildValue("(szz)", "CPython", _Py_gitidentifier(),
_Py_gitversion()));
SET_SYS_FROM_STRING("_framework", PyUnicode_FromString(PYTHONFRAMEWORK));
SET_SYS_FROM_STRING("api_version",
PyLong_FromLong(PYTHON_API_VERSION));
SET_SYS_FROM_STRING("copyright",