-
Notifications
You must be signed in to change notification settings - Fork 50
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
Lazily create code object co_code attribute. #85
Comments
I suspect that it might be quite a lot of work to get |
I think you meant If we expect that most code is never specialized, we could avoid reconstructing co_code from the specialized instructions and instead just materialize co_code when we first specialize a code object -- this will cost the same as the current cost of specialization (it has to copy the instructions to a new array which it can modify), and will slightly reduce deallocation cost compared to today (since we wouldn't have to separately free the new instructions array). I don't see big problems for The key API to change is actually What do you see as the biggest wins here?
|
Implemented in python/cpython#31888 |
When code is quickened we have two copies of the bytecode instructions.
code->co_code
(a bytearray object)code->co_firstinstr
(an array of instructions).Apart from its length (which would be trivial to add to the code object),
code->co_code
can be reconstructed fromcode->co_firstinstr
.I propose changing the code object as follows:
Current:
Proposed:
Apart from the obvious memory saving, this also allows us to streamline the interpreter a bit.
Pseudo code for generating
co_code
:The text was updated successfully, but these errors were encountered: