Skip to content

convert module initialization to use multi-phase-init #5142

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

davidhewitt
Copy link
Member

Part of #2274, inspired by all of #2245, #4081, and #4162

This converts the module initialization itself to use module slots and multi-phase init APIs. Module state is deliberately not covered here and left for follow ups. I also don't change anything related to subinterpreter checking, that is also left for a follow up.

@davidhewitt
Copy link
Member Author

Note to self: this might need to be opt-out (for a few versions) and be mentioned in the migration guide.

@mejrs
Copy link
Member

mejrs commented May 30, 2025

I like this very much!

Is this compatible with how we are currently putting pyclass' type objects in statics? We should figure out a way to store them in module state if possible.

@davidhewitt
Copy link
Member Author

I think it's sorta fine to leave the type objects in statics for now given we don't support subinterpreters, but yes:

  • we should seek to use module state if we can anyway as a followup
  • and we'd need to do so for any potential eventual subinterpreter support

@alex
Copy link
Contributor

alex commented May 30, 2025

I suppose eventually we'll want to allow users to have their own module state as well for their statics :-/

@mejrs
Copy link
Member

mejrs commented May 30, 2025

I think it's sorta fine to leave the type objects in statics for now given we don't support subinterpreters, but yes:

* we should seek to use module state if we can anyway as a followup

* and we'd need to do so for any potential eventual subinterpreter support

This will also put the nail in the coffin for #1444. I'm fine with that personally, but it'll be disappointing for quite a lot of people. Maybe we should start thinking about other ways to address that use case.

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.

3 participants