Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add _REPLACE_WITH_TRUE to the tier 2 optimizer #128195

Closed
Fidget-Spinner opened this issue Dec 23, 2024 · 1 comment
Closed

Add _REPLACE_WITH_TRUE to the tier 2 optimizer #128195

Fidget-Spinner opened this issue Dec 23, 2024 · 1 comment
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@Fidget-Spinner
Copy link
Member

Fidget-Spinner commented Dec 23, 2024

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

@Fidget-Spinner Fidget-Spinner added type-feature A feature request or enhancement easy labels Dec 23, 2024
@Fidget-Spinner
Copy link
Member Author

Fidget-Spinner commented Dec 23, 2024

This is not exactly "easy", but I documented the steps above, and the label is to signal to new contributors :).

@Eclips4 Eclips4 added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Dec 23, 2024
Fidget-Spinner pushed a commit that referenced this issue Dec 23, 2024
Add `_REPLACE_WITH_TRUE` to the tier2 optimizer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants