-
Amaury Forgeot d'Arc authored
- All built-in modules are inserted into space.builtin_modules when they are discovered, but not in sys.modules. - The end of space initialization calls setup_builtin_modules(), which calls mod.setup_after_space_initialization() for every module. At this stage, sys.modules contains the "sys" module, and other modules imported by mod.setup_after_space_initialization(). - The space and modules are frozen in this state, and translated. - When pypy-c starts, it calls mod.startup() on built-in modules already in sys.modules. - when importing another builtin module, pypy fetches it from space.builtin_modules, adds it to sys.modules, and calls its setup() method. space.getbuiltinmodule(name) is still the main interface to import-or-get a built-in module. This speeds up pypy startup, but more importantly, solves bootstraping issues where for example a higher-level module would "import posix" before it is fully initialized; when this happens, os.environ is empty!
7849d2b481e3