Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
GH-99554: marshal bytecode more efficiently#99555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
40343188b6b3935f81b82e34c46023ba8026ed83af5534112ead8f26bcd7980File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Modify the :mod:`marshal` format to serialize bytecode more efficiently. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| """ | ||
| Parts of our build process (looking at you, deepfreeze) need the opcode module | ||
| for the Python *being built*, not the Python *doing the building*. | ||
| This basically just loads ../../Lib/opcode.py: | ||
| >>> import opcode_for_build | ||
| >>> opcode = opcode_for_build.import_opcode() | ||
| """ | ||
| import os | ||
| import types | ||
| _OPCODE_PATH = os.path.realpath( | ||
| os.path.join( | ||
| os.path.dirname(__file__), os.pardir, os.pardir, "Lib", "opcode.py" | ||
| ) | ||
| ) | ||
| def import_opcode() -> types.ModuleType: | ||
| """Import the current version of the opcode module (from Lib).""" | ||
| opcode_module = types.ModuleType("opcode") | ||
| opcode_module.__file__ = os.path.realpath(_OPCODE_PATH) | ||
| with open(_OPCODE_PATH, encoding="utf-8") as opcode_file: | ||
| # Don't try this at home, kids: | ||
| exec(opcode_file.read(), opcode_module.__dict__) | ||
| return opcode_module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, sorry, I can't stomach this. It feels certain that at some point in the future we'll have a corner case where we encounter \0\0 in the middle. If an extra pass is too expensive let's just go with what you had before. Or let's not do this -- I am feeling pretty lukewarm about this scheme, especially since the register VM will require a whole new approach anyway.