Skip to content

Conversation

@erlend-aasland
Copy link
Contributor

@erlend-aaslanderlend-aasland commented Jan 29, 2023

Store the self type pointer in a local variable.

Store the self type pointer in a local variable.
@erlend-aasland
Copy link
ContributorAuthor

cc. @colorfulappl

@colorfulappl
Copy link
Contributor

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
Copy link
ContributorAuthor

  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.

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

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
Copy link
ContributorAuthor

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
Copy link
ContributorAuthor

erlend-aasland commented Jan 31, 2023

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

Copy link
Contributor

@kumaraditya303kumaraditya303 left a comment

Choose a reason for hiding this comment

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

LGTM

@erlend-aaslanderlend-aasland merged commit 2753cf2 into python:mainJan 31, 2023
@erlend-aaslanderlend-aasland deleted the clinic/self-type-check branch January 31, 2023 20:42
@erlend-aasland
Copy link
ContributorAuthor

Thanks for the reviews, y'all!

carljm added a commit to carljm/cpython that referenced this pull request Jan 31, 2023
* main: pythonGH-100288: Skip extra work when failing to specialize LOAD_ATTR (pythonGH-101354) pythongh-101409: Improve generated clinic code for self type checks (python#101411) pythongh-98831: rewrite BEFORE_ASYNC_WITH and END_ASYNC_FOR in the instruction definition DSL (python#101458) pythongh-101469: Optimise get_io_state() by using _PyModule_GetState() (pythonGH-101470)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@erlend-aasland@colorfulappl@serhiy-storchaka@kumaraditya303@bedevere-bot