Skip to content

Compact the co_code attribute of code objects. #608

Closed
@markshannon

Description

@markshannon

The co_code attribute of code object is no longer executed, it is just the representation of code on disk and for tools like dis that examine code objects. So we can optimize it for size and loading speed, not for execution speed.

We can change the bytecode format to be one byte per instruction for instruction without an oparg, and two bytes for instructions with an oparg, skipping caches.
When creating the code object, we can decompress into _co_code_adaptive performing cache initialization at the same time.

One problem would be that computing the f_lasti attribute will be expensive as we need to convert the offset in _co_code_adaptive into the offset into co_code.
We will need to do something similar for traceback objects to avoid having to do this computation when creating tracebacks.

See also #462

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