Skip to content

Merge co_names and co_consts into a single array. #92

@markshannon

Description

@markshannon

Merging co_names and co_consts would have some significant benefits:

  1. It would make code objects smaller. There is unlikely to be much sharing between names and constants, but saving two tuples per code object is significant.
  2. It would free up a register in the interpreter which should be worth a few percent speed up (in the interpreter, less overall).
  3. By using an array, not a tuple, some lazy initialization of constants becomes possible. For example, a deep-frozen module might not be able to include frozen sets due to hashing; tuples could be stored and converted to frozen-sets on code object initialization.

The obvious downside is for functions where the total number of names and constants exceeds 256. I hypothesize that those functions are rare, but don't have data to confirm that.

This is probably best left until https://bugs.python.org/issue36521 has been resolved.

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