forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bpo-45696: Deep-freeze selected modules (pythonGH-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.
- Loading branch information
1 parent
fc9b622
commit 1cbaa50
Showing
16 changed files
with
808 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Build/2021-11-03-00-19-50.bpo-45696.eKs46f.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Skip the marshal step for frozen modules by generating C code that produces a set of ready-to-use code objects. This speeds up startup time by another 10% or more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
This directory contains the generated .c files for all the deep-frozen | ||
modules. Python/frozen.c depends on these files. | ||
|
||
None of these files are committed into the repo. | ||
|
||
See Tools/scripts/freeze_modules.py for more info. |
Oops, something went wrong.