pyo3
pyo3 copied to clipboard
RFC: Implement Multi-Phase Module Initialization as per PEP 489
RFC: Multi-Phase Module Initialization as per PEP 489
This PR implements multi-phase initialization in PyO3 as a drop-in replacement for single phase initialization. While it still needs some polish here and there, the implementation is mostly complete.
What's still left to do:
- [x] Figure out how to add submodules again - needs some kind of support for creating
m_slotsor perhaps an API around creatingPyModuleDefs- This works now, thanks to a mechanism that makes it possible to (de-facto) statically allocate
m_slotsat runtime.
- This works now, thanks to a mechanism that makes it possible to (de-facto) statically allocate
- [ ] Reliably get a
Py<PyModule>from a*mut ffi::PyModuleDef- Is this even possible? If not, we'll require some API breaking, I fear
- [ ] Improve error handling - currently panics if calling the module setup function (
#ident(#(#module_args),*)in proc macros) fails - [ ] Implement multi-phase initialization for
PyModule::new_bound- I wonder if this is actually necessary, though.
- [ ] Address remaining TODOs
- [ ] Rephrase commit messages / perhaps split up commits
- The messages could IMO be somewhat more detailed, elaborating on the reasoning behind certain changes / additions
Please let me know what you think! I'm grateful for any feedback! :)
Specifically, I'd be very happy to receive insight / comments on the TODOs I've added here and there.
Upgraded this PR from a draft to an RFC. The description was also updated to reflect that.