Skip to content

bpo-33124: WIP: lazy execution of module bytecode#6194

Closed
nascheme wants to merge 10 commits into
python:masterfrom
nascheme:lazy_module
Closed

bpo-33124: WIP: lazy execution of module bytecode#6194
nascheme wants to merge 10 commits into
python:masterfrom
nascheme:lazy_module

Conversation

@nascheme

@nascheme nascheme commented Mar 22, 2018

Copy link
Copy Markdown
Member

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

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'.
@nascheme

Copy link
Copy Markdown
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.

nascheme added 2 commits May 2, 2018 19:29
Our inserted code must come *after* the future imports.  Fix an
off-by-one error.
@csabella

csabella commented Jul 3, 2019

Copy link
Copy Markdown
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!

@nascheme

nascheme commented Jul 4, 2019

Copy link
Copy Markdown
Member Author

I will close. The idea might still have merit (bit doubtful) but I still have the branch stashed away.

@nascheme nascheme closed this Jul 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants