Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
61207d2e281791e45c2804eade4aa2bba452bb095bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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 || | ||||||||
Contributor 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 Member 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.
Uh oh!
There was an error while loading. Please reload this page.
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!