The python docs state:
A complete Python program is executed in a minimally initialized environment: all built-in and standard modules are available, but none have been initialized, except for
sys(various system services),builtins(built-in functions, exceptions and None) and__main__.
This would suggest that only those three modules should be listed as loaded modules with the following code snippet:
import sys
print(sys.modules.keys())
However, running the code snippet using CPython v3.10 (with -S option) returns the following on my PC:
dict_keys(['sys', 'builtins', '_frozen_importlib', '_imp', '_thread', '_warnings', '_weakref', '_io', 'marshal', 'nt', 'winreg', '_frozen_importlib_external', 'time', 'zipimport', '_codecs', 'codecs', 'encodings.aliases', 'encodings', 'encodings.utf_8', 'encodings.cp1252', '_signal', '_abc', 'abc', 'io', '__main__'])
Why are there 22 extra modules loaded at runtime as compared to the "minimally initialized environment" mentioned in the docs?
I am updating my understanding of CPython's extra loaded modules with my own answer below.