-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
[EDIT: See below why there is little or no value in a compact form of LOAD_GLOBAL]
Module and class level code is "run once". It can, in theory be run many times, but it is generally run only once.
The existence of caches for this code is quite wasteful, in terms of space.
LOAD_GLOBAL takes 10 bytes, and LOAD_ATTR takes 20.
We should add LOAD_GLOBAL_COMPACT and LOAD_ATTR_COMPACT bytecodes, which would behave like LOAD_GLOBAL and LOAD_ATTR but without counters or cache, so would only take 2 bytes each.
The compiler can easily tell whether code is a "run once" context and emit the correct instruction.
With PEP 649 on the horizon, there will be even more "run once" code in the form of annotation closures and code objects.
carljm
Metadata
Metadata
Assignees
Labels
No labels