mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-31415: Support PYTHONPROFILEIMPORTTIME envvar equivalent to -X importtime (#4240)
Support PYTHONPROFILEIMPORTTIME envvar equivalent to -X importtime
This commit is contained in:
parent
9e33973332
commit
700d2e4755
3 changed files with 25 additions and 7 deletions
|
@ -1682,10 +1682,17 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
|
|||
* _PyDict_GetItemId()
|
||||
*/
|
||||
if (ximporttime == 0) {
|
||||
PyObject *xoptions = PySys_GetXOptions();
|
||||
if (xoptions) {
|
||||
PyObject *value = _PyDict_GetItemId(xoptions, &PyId_importtime);
|
||||
ximporttime = (value == Py_True);
|
||||
char *envoption = Py_GETENV("PYTHONPROFILEIMPORTTIME");
|
||||
if (envoption != NULL && strlen(envoption) > 0) {
|
||||
ximporttime = 1;
|
||||
}
|
||||
else {
|
||||
PyObject *xoptions = PySys_GetXOptions();
|
||||
if (xoptions) {
|
||||
PyObject *value = _PyDict_GetItemId(
|
||||
xoptions, &PyId_importtime);
|
||||
ximporttime = (value == Py_True);
|
||||
}
|
||||
}
|
||||
if (ximporttime) {
|
||||
fputs("import time: self [us] | cumulative | imported package\n",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue