Skip to content

bpo-43770: Refactor PyType_Ready() function #25336

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
Apr 11, 2021
Merged

bpo-43770: Refactor PyType_Ready() function #25336

merged 2 commits into from
Apr 11, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Apr 10, 2021

  • Split PyType_Ready() into sub-functions.
  • type_ready_mro() now checks if bases are static types earlier.
  • Check tp_name earlier, in type_ready_checks().
  • Add _PyType_IsReady() macro to check if a type is ready.

https://bugs.python.org/issue43770

* Split PyType_Ready() into sub-functions.
* type_ready_mro() now checks if bases are static types earlier.
* Check tp_name earlier, in type_ready_checks().
* Add _PyType_IsReady() macro to check if a type is ready.
}


/* Some more special stuff */
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'd either remove this comment, or write something more explanatory :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried to not make too many changes at once. After this large refactoring, I hope that it will be way easier to cleanup and enhance the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I concur that the comment is useless :-) But I only moved it, I didn't want to rewrite it in this PR. My plan is to fix https://bugs.python.org/issue43770#msg390519 But I had to refactor the existing code since it was very fragile and hard to modify.

Copy link
Contributor

Choose a reason for hiding this comment

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

I tried to not make too many changes at once.

No stress; it's hard enough to get nice diffs when refactoring :)

After this large refactoring, I hope that it will be way easier to cleanup and enhance the code.

The refactored code is much more comprehensible and self-documenting! Thank you :)

Co-authored-by: Erlend Egeberg Aasland <[email protected]>
@vstinner vstinner merged commit 53114ff into python:master Apr 11, 2021
@vstinner vstinner deleted the type_ready branch April 11, 2021 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants