◐ Shell
clean mode source ↗

gh-101409: Improve generated clinic code for self type checks by erlend-aasland · Pull Request #101411 · python/cpython

Store the self type pointer in a local variable.

@erlend-aasland

@colorfulappl

I'm not sure if this improvement is worth it, though; it may be churn for no benefit.

IMHO, this improvement is worth it.

  1. If the clinic_state() macro is fairly complicated, the compiler won't eliminate the redundant function invocations.

  2. The generated code after this patch is more concise and readable.

@erlend-aasland

  1. If the clinic_state() macro is fairly complicated, the compiler won't eliminate the redundant function invocations.

That is true; we cannot guarantee that the compiler will eliminate the redundant calls.

  1. The generated code after this patch is more concise and readable.

I agree with this.

Thanks for the review, @colorfulappl; highly appreciated.

serhiy-storchaka

Choose a reason for hiding this comment

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

self_tp may be not a good name. It is not a type of self. Maybe base_type or declared_type or something?

@erlend-aasland

self_tp may be not a good name. It is not a type of self. Maybe base_type or declared_type or something?

base_type sounds good; thanks!

@erlend-aasland

I'm considering landing this PR in a day or two. With three thumbs up, I'm landing this tonight.

kumaraditya303

Choose a reason for hiding this comment

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

LGTM

serhiy-storchaka

@erlend-aasland

Thanks for the reviews, y'all!

carljm added a commit to carljm/cpython that referenced this pull request

Jan 31, 2023