-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
gh-139757: Add BINARY_OP_SUBSCR_USTR_INT #143389
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
Conversation
passes the tests and brings bm_tomli back to normal, i.e. 15 % speedup
|
I verified a 9% speedup on this PR for the Apparently, we regressed earlier in https://github.com/python/cpython/pull/140800/files. This caused the 10% slowdown in tomli loads. Which seemingly uses a lot of unicode strings. I'm going to merge this PR to remove the perf regression. |
Fidget-Spinner
left a comment
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.
Just need tests and two comments. Thanks!
Python/bytecodes.c
Outdated
| res = PyStackRef_FromPyObjectBorrow(res_o); | ||
| } | ||
|
|
||
| macro(BINARY_OP_SUBSCR_NCSTR_INT) = |
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.
When you have the time, please change then name to BINARY_OP_SUBSCR_USTR_INT.
Python/bytecodes.c
Outdated
| } | ||
|
|
||
| macro(BINARY_OP_SUBSCR_NCSTR_INT) = | ||
| _GUARD_TOS_INT + _GUARD_NOS_UNICODE + unused/5 + _BINARY_OP_SUBSCR_NCSTR_INT + _POP_TOP_INT + POP_TOP; |
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.
Is POP_TOP_UNICODE instead of POP_TOP safe here?
| self.assertNotIn("_GUARD_TOS_UNICODE", uops) | ||
| self.assertIn("_BINARY_OP_ADD_UNICODE", uops) | ||
|
|
||
| def test_binary_subcsr_ustr_int_narrows_to_str(self): |
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.
I thought of paramterizing test_binary_subcsr_str_int_narrows_to_str and test_binary_op_subscr_str_int to get rid of duplication, but it resulted in worse readable code, because the input and the expectations have to be varied ...
|
Sorry for leaving 3 separate review comments instead of one review. I only picked up on some of these while looking over them again. |
Fidget-Spinner
left a comment
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.
LGTM. Thanks.
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
|
Since #140800
BINARY_OP_SUBSCR_STR_INTonly specializes for compact ASCII strings. Let's introduceBINARY_OP_SUBSCR_USTR_INTto specialize again for reading an ASCII character from any string.