Issue #22557: Now importing already imported modules is up to 2.5 times faster.

This commit is contained in:
Serhiy Storchaka 2016-08-02 22:51:21 +03:00
parent cde03fa038
commit 133138a284
6 changed files with 244 additions and 252 deletions

View file

@ -254,6 +254,11 @@ import_init(PyInterpreterState *interp, PyObject *sysmod)
interp->importlib = importlib;
Py_INCREF(interp->importlib);
interp->import_func = PyDict_GetItemString(interp->builtins, "__import__");
if (interp->import_func == NULL)
Py_FatalError("Py_Initialize: __import__ not found");
Py_INCREF(interp->import_func);
/* Import the _imp module */
impmod = PyInit_imp();
if (impmod == NULL) {