diff options
author | Barry Warsaw <barry@python.org> | 2017-11-02 23:13:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-02 23:13:36 (GMT) |
commit | 700d2e4755921d6c339ff20dacecde1aea64de34 (patch) | |
tree | ce746ff976847c80a63b88a5d6795fa1dd8b7551 /Python | |
parent | 9e3397333278f973a11d933c27a69af250e4acf0 (diff) | |
download | cpython-700d2e4755921d6c339ff20dacecde1aea64de34.zip cpython-700d2e4755921d6c339ff20dacecde1aea64de34.tar.gz cpython-700d2e4755921d6c339ff20dacecde1aea64de34.tar.bz2 |
bpo-31415: Support PYTHONPROFILEIMPORTTIME envvar equivalent to -X importtime (#4240)
Support PYTHONPROFILEIMPORTTIME envvar equivalent to -X importtime
Diffstat (limited to 'Python')
-rw-r--r-- | Python/import.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Python/import.c b/Python/import.c index d396b4d..7ba1842 100644 --- a/Python/import.c +++ b/Python/import.c @@ -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", |