Skip to content

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

Merged
merged 2 commits into from
Feb 21, 2020
Merged

Conversation

deiuch
Copy link
Contributor

@deiuch deiuch commented Nov 14, 2019

Trivial change

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.

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.
@brandtbucher
Copy link
Member

Thanks for your time @deiuch, and welcome to CPython!

@brandtbucher brandtbucher added skip news type-feature A feature request or enhancement labels Nov 14, 2019
Copy link
Member

@brandtbucher brandtbucher left a 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)?

@deiuch
Copy link
Contributor Author

deiuch commented Nov 14, 2019

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. PREDICTED is a label statement, which is intended for use as a "landing pad" of goto's that address prediction of the given operator. There is a trailing colon character :)

Copy link
Member

@brandtbucher brandtbucher left a 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!

Copy link
Contributor

@taleinat taleinat left a 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.

Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, thank you.

@pitrou
Copy link
Member

pitrou commented Feb 21, 2020

Opcode prediction is disabled on gcc / clang builds and enabled on MSVC, so both cases should be exercised by CI. Merging.

@pitrou pitrou merged commit baf29b2 into python:master Feb 21, 2020
@serhiy-storchaka
Copy link
Member

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.

@deiuch
Copy link
Contributor Author

deiuch commented Feb 21, 2020

@serhiy-storchaka, you mean it is now harder to read with your IDE?

@serhiy-storchaka
Copy link
Member

I do not use IDE.

@brandtbucher
Copy link
Member

Congrats on your first CPython contribution, @deiuch! 🍾

Looking forward to seeing more from you in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip issue skip news type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants