Uh oh!
There was an error while loading. Please reload this page.
gh-116146: Add C-API to create module from spec and initfunc - #139196
Conversation
f9cd705 to
4363e5aCompare
encukou
left a comment
There was a problem hiding this comment.
This looks reasonable.
I'm proposing a replacement for Init functions in PEP-793, but that PEP adds PyModule_FromSlotsAndSpec and PyModule_Exec which should work for similar use cases.
Would it make sense to switch the spec & initfunc arguments to match that proposal?
I'm not sure if the word Builtin in the name is necessary -- is that to match the internal create_builtin? Would something like PyImport_LoadModuleFromInitfuncAndSpec work better?
Do you want to submit this to the C API WG?
Uh oh!
There was an error while loading. Please reload this page.
itamaro
commented
Sep 23, 2025
I think it should be fine! Is the PEP already implemented on main?
Yes, I used it to reflect what it does internally.
Will do. Should we first decide whether to change this to match PEP 793, or go to the WP with options and get their input? |
encukou
commented
Sep 24, 2025
No, it's not even accepted :)
Just go to the WG :) |
itamaro
commented
Sep 24, 2025
done :) capi-workgroup/decisions#77 |
Uh oh!
There was an error while loading. Please reload this page.
- use `PyImport_CreateModuleFromInitfunc` for the new API - no need to introduce `create_builtin_ex` - update `create_builtin` and all callers - update exception message
4363e5a to
781a730CompareUh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
encukou
commented
Nov 11, 2025
I left my suggestions as a PR: itamaro#27 |
* Test single-phase init as well; don't use private APIs in test * Doc update --------- Co-authored-by: Itamar Oren <itamarost@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <vstinner@python.org>
…on under the free-threaded build
8f16533 to
1165950Compareitamaro
commented
Nov 12, 2025
vstinner
left a comment
There was a problem hiding this comment.
The new function PyImport_CreateModuleFromInitfunc() should be documented in Doc/whatsnew/3.15.rst.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
fabafb5 to
fbfde0aCompareUh oh!
There was an error while loading. Please reload this page.
vstinner
commented
Nov 14, 2025
Congrats @itamaro! |
…ythonGH-139196) Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
C-API WG decision: capi-workgroup/decisions#77