Skip to content

GH-119500: Remove slice opcodes and handle constant slices in the compiler. #119502

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

Closed
wants to merge 7 commits into from

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented May 24, 2024

This PR:

  • Removes the BINARY_SLICE and STORE_SLICE opcodes
  • Converts constant slices to constants in the AST optimizer.
  • Merges the free-threading and normal code comparison functions, to handle equal, but not identical code objects.

Comment on lines +1931 to +1932
if (compare_constants(PyTuple_GET_ITEM(op1, i),
PyTuple_GET_ITEM(op2, i)) == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (compare_constants(PyTuple_GET_ITEM(op1, i),
PyTuple_GET_ITEM(op2, i)) == 0) {
if (compare_constants(PyTuple_GET_ITEM(op1, i),
PyTuple_GET_ITEM(op2, i)) == 0) {

goto cleanup;
}
retval = PySlice_New(start, stop, step);
assert(retval != NULL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert? Not memory error?

@@ -1484,6 +1492,7 @@ r_object(RFILE *p)

v = (PyObject *)_PyCode_New(&con);
if (v == NULL) {
assert(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@brettcannon brettcannon removed their request for review June 11, 2024 20:33
@markshannon
Copy link
Member Author

Handling constant slices might be worthwhile, but it looks like we are better off keeping BINARY_SLICE for now.

@markshannon markshannon deleted the remove-slice-opcodes branch August 6, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants