Skip to content

Add _REPLACE_WITH_TRUE to the tier 2 optimizer #128195

@Fidget-Spinner

Description

@Fidget-Spinner

Feature or enhancement

Proposal:

_REPLACE_WITH_TRUE is not currently in the tier 2 optimizer's known list, resulting in some missed opportunities.

To add it, here are the following steps:

  1. Add a new bytecode definition _REPLACE_WITH_TRUE in Python/optimizer_bytecodes.c, with the same header as the one in Python/bytecodes.c.
  2. The body of the instruction in optimizer_bytecodes.c should say res = sym_new_const(ctx, Py_True);. Meaning that the new value is a new symbolic constant of the value "True".
  3. Run make regen-cases on *nix.
  4. You can add a test in Lib/test/test_capi/test_opt.py. This is optional, you can choose not to as well.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    easyinterpreter-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