-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Reuse identifier of PREDICT macros as PREDICT_ID #17155
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
In function `_PyEval_EvalFrameDefault`, macros PREDICT and PREDICTED use the same identifier creation scheme, which may be shared between them, reducing code repetition, and do ensure that the same identifier is generated.
Thanks for your time @deiuch, and welcome to CPython! |
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 don't think we need a third macro. In your changes, PREDICTED
and PREDICT_ID
are aliases, right?
So why not just replace the two occurrences of PRED_##op
in the definition of PREDICT
with PREDICTED(op)
?
They are a bit different constructs. |
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.
Ah, I missed the colon. This looks good, then!
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.
Indeed, looks good. I'll wait for input from someone with more experience with this C code though.
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.
+1, thank you.
Opcode prediction is disabled on gcc / clang builds and enabled on MSVC, so both cases should be exercised by CI. Merging. |
It reduced readability of the code to me. I need now to search the definition of a new macro when I read definitions of PREDICT and PREDICTED, and it is not easy with my conditions. |
@serhiy-storchaka, you mean it is now harder to read with your IDE? |
I do not use IDE. |
Congrats on your first CPython contribution, @deiuch! 🍾 Looking forward to seeing more from you in the future. |
Trivial change
In function
_PyEval_EvalFrameDefault
, macrosPREDICT
andPREDICTED
use the same identifier creation scheme, which may be shared between them, reducing code repetition, and do ensure that the same identifier is generated.