classification
Title: Lazy execution of module bytecode
Type: enhancement Stage: patch review
Components: Interpreter Core Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: barry, brett.cannon, josh.r, nascheme, serhiy.storchaka
Priority: low Keywords: patch

Created on 2018-03-22 22:17 by nascheme, last changed 2018-03-28 15:18 by josh.r.

Pull Requests
URL Status Linked Edit
PR 6194 open nascheme, 2018-03-22 22:18
Messages (3)
msg314294 - (view) Author: Neil Schemenauer (nascheme) * (Python committer) Date: 2018-03-22 22:17
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.
msg314505 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-27 09:03
Function definitions usually are cheap, as well as global constants definitions (unless they use complex comprehensions or call heavy functions for initialization). Creating a class is an order or more slower than creating a function. Creating enums and namedtuples is an order or two slower than creating a plain class.
msg314606 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2018-03-28 15:18
Serhiy: There is a semi-common case where global constants can be quite expensive, specifically, initializing a global full of expensive to compute/serialize data so it will be shared post-fork when doing multiprocessing on a POSIX system. That said, that would likely be a case where lazy initialization would be a problem; you don't want each worker independently initializing the global lazily.

Also, for all practical purposes, aren't enums and namedtuples global constants too? Since they don't rely on any syntax based support at point of use, they're just a "function call" followed by assignment to a global name; you couldn't really separate the concept of global constants from enums/namedtuple definitions, right?
History
Date User Action Args
2018-03-28 15:18:32josh.rsetnosy: + josh.r
messages: + msg314606
2018-03-27 09:03:59serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg314505
2018-03-22 23:07:20brett.cannonsetnosy: + brett.cannon
2018-03-22 22:45:15barrysetnosy: + barry
2018-03-22 22:18:49naschemesetkeywords: + patch
pull_requests: + pull_request5941
2018-03-22 22:17:11naschemecreate