bpo-33124: WIP: lazy execution of module bytecode#6194
Closed
nascheme wants to merge 10 commits into
Closed
Conversation
If <module>.__dict__[<name>] does not exist and <module>.__lazy_code__[<name>] does exist, evaluate the code and then return <module>.<name>. This allows the implementation of lazy module imoprts and lazy module top-level definitions.
This is an alternative to compile_all.py. If the module has __lazy_module__ in the globals (i.e. explicitly marked as lazy safe), top level definitions in the module will become lazy loaded. I.e. the code that is evaluated to create the object will not be evaluated until LOAD_NAME/LOAD_GLOBAL or module getattr() looks for it.
Rather than marking the whole module as lazy safe or not, print a list of top-level module definitions, classifying them as 'lazy' or 'eager'.
Member
Author
|
Just to be clear, this is not something I wish to merge at this point. If we are going to do something like this, it will certainly require a PEP. |
Our inserted code must come *after* the future imports. Fix an off-by-one error.
Contributor
|
@nascheme, since there are a lot of merge conflicts with this now, did you want to close it pending the further review that you mentioned or would you prefer to leave it open? Thanks! |
Member
Author
|
I will close. The idea might still have merit (bit doubtful) but I still have the branch stashed away. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an experimental patch that implements lazy execution of top-level definitions in modules (functions, classes, imports, global constants). See Tools/lazy_compile/README.txt for details.
https://bugs.python.org/issue33124