Skip to content

Use PyMarshal_WriteToString for logic of _PyCode_ConstantKeyΒ #126411

@mdboom

Description

@mdboom

Feature or enhancement

Proposal:

As @brandtbucher mentioned elsewhere, _PyCode_ConstantKey is getting to be quite large, subtle and error-prone. The unique key that PyMarshal_WriteToString creates would serve the same purpose and would replace the logic with something core and well-tested.

In addition to correctness, it should also be tested for any performance impact. It's possible it's moot since _PyCode_ConstantKey already allocates a bunch of objects, but we should confirm.

intern_constants also does mostly the same thing in a free-threaded build and maybe could take a similar approach to also remove a bunch of code that is hard to keep in-sync with everything else.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions