Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
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 ourterms of service andprivacy 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.
Conversation
passes the tests and brings bm_tomli back to normal, i.e.15 % speedup
Fidget-Spinner commentedJan 3, 2026
I verified a 9% speedup on this PR for the Apparently, we regressed earlier inhttps://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 toBINARY_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?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| 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 paramterizingtest_binary_subcsr_str_int_narrows_to_str andtest_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 ...
Uh oh!
There was an error while loading.Please reload this page.
Fidget-Spinner commentedJan 4, 2026
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.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
e6bfe4d intopython:mainUh oh!
There was an error while loading.Please reload this page.
bedevere-bot commentedJan 4, 2026
|
Uh oh!
There was an error while loading.Please reload this page.
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.