-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-131798: JIT: Assign type to sliced string/list/tuple #134671
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
Changes from all commits
61207d2
e281791
e45c280
4eade4a
a2bba45
2bb095b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Make the JIT optimizer understand that slicing a string/list/tuple returns the same type. |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -1216,6 +1216,20 @@ dummy_func(void) { | |||||||
sym_set_const(callable, list_append); | ||||||||
} | ||||||||
|
||||||||
op(_BINARY_SLICE, (container, start, stop -- res)) { | ||||||||
// Slicing a string/list/tuple always returns the same type. | ||||||||
PyTypeObject *type = sym_get_type(container); | ||||||||
if (type == &PyUnicode_Type || | ||||||||
type == &PyList_Type || | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I do not know whether slicing a bytes object occurs often enough to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fluhus, this PR is probably fine for now, but feel free to add other sequence types like this in a follow-up PR (with tests)! |
||||||||
type == &PyTuple_Type) | ||||||||
{ | ||||||||
res = sym_new_type(ctx, type); | ||||||||
} | ||||||||
else { | ||||||||
res = sym_new_not_null(ctx); | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
// END BYTECODES // | ||||||||
|
||||||||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!