◐ Shell
clean mode source ↗

Message 270592 - Python tracker

This issue continues #25507.  I still want to reduce the number of modules imported when run.py starts a user process and the time they require.  In the process, I expect to reduce the number of tkinter module imports that need to be reversed and thereby make parts of the #25507 fix unnecessary.

"New changeset 93d325c64104 by Terry Jan Reedy in branch 'default':
Issue #25507: Move 4 objects from pyshell to run and switch inports.
https://hg.python.org/cpython/rev/93d325c64104"

This commit for #25507 was not needed for the fix I eventually choose, but it reduced the size of sys.modules in the user process from 193 to 156.  I have since determined that it reduced the time for startup imports on my machine from .45 to .25 seconds.  I now regard it as the first patch for this issue.

The attached file was explained in msg270522.  This and similar refactorings should be done when or after I have otherwise revised the module and tests in question.

For a Windows build of repository 3.6, importing tkinter into a fresh python process increases len(sys.modules) from 41 to 65.  But run only imports tkinter so it can call _tkinter.tkapp().eval('update') in its interactive input loop.  If other indirect imports were eliminated, I suspect _tkinter could be imported instead.