Multi-phase module initialization implemented #505
pyscripter
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In #442, it was discussed how to use sub-interpreters to achieve true parallelism using python 3.12. In python 3.14 sub-interpreters are exposed to python code through a new module concurrent. Interpreters. There interpreters are isolated environments with their own GIL that can run in parallel. There are still serious limitations and one of them relates to what modules can be imported. The modules need to support multi-phase initialization to be able to be used. with such interpreters.
Support for creating extension modules with multi-phase initialization has been added to P4D.
The demo DemoModule and RTTIModule projects have been updated to showcase this new feature.
There are quite a few internal changes, but the only public change is a new property for TPythonModule:
TMultIntperpretersSupport = (mmiSupported, mmiNotSupported, mmiPerInterpreterGIL); property MultInterpretersSupport: TMultIntperpretersSupport read FMultInterpretersSupport write FMultInterpretersSupport;
By default P4D extension modules support sub-interpreters but not those with their own GIL. When you create an extension module, you will need to set MultInterpretersSupport to mmiPerInterpreterGIL to support the new interpreters module. You can use the two demo modules as a guide.
In DemoModule you will also find a python test file InterpreterExecutor.py that shows how to use the new InterpreterPoolEecutor with the P4D extension module. Note that you need to use python 3.14 for running this demo.
Beta Was this translation helpful? Give feedback.
All reactions