diff options
author | Guido van Rossum <guido@python.org> | 2021-11-11 02:01:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-11 02:01:53 (GMT) |
commit | 1cbaa505d007e11c4a1f0d2073d72b6c02c7147c (patch) | |
tree | 671391d64df20ebcf2960fae83030e61f5527aa3 /Python/bootstrap_frozen.c | |
parent | fc9b62281931da8d20f85d5ed44cfc24f068d3f4 (diff) | |
download | cpython-1cbaa505d007e11c4a1f0d2073d72b6c02c7147c.zip cpython-1cbaa505d007e11c4a1f0d2073d72b6c02c7147c.tar.gz cpython-1cbaa505d007e11c4a1f0d2073d72b6c02c7147c.tar.bz2 |
bpo-45696: Deep-freeze selected modules (GH-29118)
This gains 10% or more in startup time for `python -c pass` on UNIX-ish systems.
The Makefile.pre.in generating code builds on Eric's work for bpo-45020, but the .c file generator is new.
Windows version TBD.
Diffstat (limited to 'Python/bootstrap_frozen.c')
-rw-r--r-- | Python/bootstrap_frozen.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Python/bootstrap_frozen.c b/Python/bootstrap_frozen.c new file mode 100644 index 0000000..68ba147 --- /dev/null +++ b/Python/bootstrap_frozen.c @@ -0,0 +1,45 @@ + +/* Frozen modules bootstrap */ + +/* This file is linked with "bootstrap Python" + which is used (only) to run Tools/scripts/deepfreeze.py. */ + +#include "Python.h" +#include "pycore_import.h" + +/* Includes for frozen modules: */ +#include "frozen_modules/importlib._bootstrap.h" +#include "frozen_modules/importlib._bootstrap_external.h" +#include "frozen_modules/zipimport.h" +/* End includes */ + +/* Note that a negative size indicates a package. */ + +static const struct _frozen bootstrap_modules[] = { + {"_frozen_importlib", _Py_M__importlib__bootstrap, (int)sizeof(_Py_M__importlib__bootstrap)}, + {"_frozen_importlib_external", _Py_M__importlib__bootstrap_external, (int)sizeof(_Py_M__importlib__bootstrap_external)}, + {"zipimport", _Py_M__zipimport, (int)sizeof(_Py_M__zipimport)}, + {0, 0, 0} /* bootstrap sentinel */ +}; +static const struct _frozen stdlib_modules[] = { + {0, 0, 0} /* stdlib sentinel */ +}; +static const struct _frozen test_modules[] = { + {0, 0, 0} /* test sentinel */ +}; +const struct _frozen *_PyImport_FrozenBootstrap = bootstrap_modules; +const struct _frozen *_PyImport_FrozenStdlib = stdlib_modules; +const struct _frozen *_PyImport_FrozenTest = test_modules; + +static const struct _module_alias aliases[] = { + {"_frozen_importlib", "importlib._bootstrap"}, + {"_frozen_importlib_external", "importlib._bootstrap_external"}, + {0, 0} /* aliases sentinel */ +}; +const struct _module_alias *_PyImport_FrozenAliases = aliases; + + +/* Embedding apps may change this pointer to point to their favorite + collection of frozen modules: */ + +const struct _frozen *PyImport_FrozenModules = NULL; |