sys.modules

Terry Reedy tjreedy at udel.edu
Thu Feb 21 22:54:14 EST 2019


On 2/21/2019 11:40 AM, ast wrote:
> Hello
> 
> Is it normal to have 151 entries in dictionary sys.modules
> just after starting IDLE or something goes wrong ?

The is the right number.  When Python starts, it imports around 50 
modules.  When it runs IDLE, most of idlelib modules are imported, plus 
about 50 stdlib modules, including 4 or 5 tkinter modules.  IDLE used to 
import many more modules, but I managed to delay some until needed, and 
reduced the startup time by about 25%.

>  >>> import sys
>  >>> len(sys.modules)
> 151

Since this is your code, the report is for the user-code execution 
process, as opposed to the IDLE GUI process.  Both processes are running 
when you get the prompt.

-- 
Terry Jan Reedy




More information about the Python-list mailing list