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

Treat slices with constant parts as constants and remove BINARY_SLICE opcodes #119500

Closed
markshannon opened this issue May 24, 2024 · 1 comment
Closed

Comments

@markshannon
Copy link
Member

markshannon commented May 24, 2024

This is in support of #118093, where we want to merge BINARY_SUBSCR into BINARY_OP.

Prior to merging BINARY_SUBSCR into BINARY_OP, we want to get rid of the BINARY_SLICE opcodes as they complicate specialization. Without BINARY_SLICE we want to treat constant slices as constants, to reduce the overhead of computing slices.

With this change the bytecode for seq[:-1] goes from:

  LOAD_FAST                0 (seq)
  LOAD_CONST               0 (None)
  LOAD_CONST               1 (-1)
  BINARY_SLICE

to:

  LOAD_FAST                0 (seq)
  LOAD_CONST               1 (slice(None, -1, None))
  BINARY_SUBSCR

Linked PRs

@markshannon markshannon changed the title Treat constant slices as slices and remove BINARY_SLICE opcodes Treat slices with constant parts as constants and remove BINARY_SLICE opcodes May 24, 2024
@markshannon
Copy link
Member Author

Benchmarking suggests that it is worth keeping BINARY_SLICE. If we implement tagged ints, the performance benefit of BINARY_SLICE is likely to increase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant