Skip to content

Compact version of LOAD_ATTR #583

@markshannon

Description

@markshannon

[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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions