| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -966,6 +966,7 @@ Beomsoo Bombs Kim | |
| Derek D. Kim | ||
| Gihwan Kim | ||
| Jan Kim | ||
| Noah Kim | ||
| Taek Joo Kim | ||
| Yeojin Kim | ||
| Sam Kimbrel | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| :option:`-X importtime <-X>` now accepts value ``2``, which indicates that | ||
| an ``importtime`` entry should also be printed if an imported module has | ||
| already been loaded. | ||
| Patch by Noah Kim and Adam Turner. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -103,6 +103,15 @@ static struct _inittab *inittab_copy = NULL; | |
| #define FIND_AND_LOAD(interp) \ | ||
| (interp)->imports.find_and_load | ||
|
|
||
| #define _IMPORT_TIME_HEADER(interp) \ | ||
| do { \ | ||
| if (FIND_AND_LOAD((interp)).header) { \ | ||
| fputs("import time: self [us] | cumulative | imported package\n", \ | ||
| stderr); \ | ||
| FIND_AND_LOAD((interp)).header = 0; \ | ||
| } \ | ||
| } while (0) | ||
|
|
||
|
|
||
| /*******************/ | ||
| /* the import lock */ | ||
| Expand Down Expand Up | @@ -246,16 +255,33 @@ import_ensure_initialized(PyInterpreterState *interp, PyObject *mod, PyObject *n | |
| rc = _PyModuleSpec_IsInitializing(spec); | ||
| Py_DECREF(spec); | ||
| } | ||
| if (rc <= 0) { | ||
| if (rc == 0) { | ||
| goto done; | ||
| } | ||
| else if (rc < 0) { | ||
| return rc; | ||
| } | ||
|
|
||
| /* Wait until module is done importing. */ | ||
| PyObject *value = PyObject_CallMethodOneArg( | ||
| IMPORTLIB(interp), &_Py_ID(_lock_unlock_module), name); | ||
| if (value == NULL) { | ||
| return -1; | ||
| } | ||
| Py_DECREF(value); | ||
|
|
||
| done: | ||
| /* When -X importtime=2, print an import time entry even if an | ||
| imported module has already been loaded. | ||
| */ | ||
| if (_PyInterpreterState_GetConfig(interp)->import_time == 2) { | ||
| _IMPORT_TIME_HEADER(interp); | ||
| #define import_level FIND_AND_LOAD(interp).import_level | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhy use a macro here?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI wanted to mirror line 3652 (import_find_and_load) as closely as possible--since it's only used once I can get rid of the macro if you prefer.
Sorry, something went wrong.
All reactions
|
||
| fprintf(stderr, "import time: cached | cached | %*s\n", | ||
| import_level*2, PyUnicode_AsUTF8(name)); | ||
| #undef import_level | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| Expand Down Expand Up | @@ -3686,13 +3712,7 @@ import_find_and_load(PyThreadState *tstate, PyObject *abs_name) | |
| * _PyDict_GetItemIdWithError(). | ||
| */ | ||
| if (import_time) { | ||
| #define header FIND_AND_LOAD(interp).header | ||
| if (header) { | ||
| fputs("import time: self [us] | cumulative | imported package\n", | ||
| stderr); | ||
| header = 0; | ||
| } | ||
| #undef header | ||
| _IMPORT_TIME_HEADER(interp); | ||
|
|
||
| import_level++; | ||
| // ignore error: don't block import if reading the clock fails | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.