Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Multi-phase module initialization implemented#505

Discussion options

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 moduleconcurrent. 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 supportmulti-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 demoDemoModule andRTTIModule projects have been updated to showcase this new feature.

There are quite a few internal changes, but the only public change is a two new properties for TPythonModule:

  TMultIntperpretersSupport = (mmiSupported, mmiNotSupported, mmiPerInterpreterGIL);publicproperty IsExtensionModule: Boolean read FIsExtensionModule write FIsExtensionModule;publishedproperty 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.

InDemoModule you will also find a python test fileInterpreterExecutor.py that shows how to use the newInterpreterPoolEecutor with the P4D extension module. Note that you need to use python 3.14 for running this demo.

Note that the old way of creating extension modules still works. But these extension modules are not compatible with sub-interpreters.

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
1 participant
@pyscripter

[8]ページ先頭

©2009-2025 Movatter.jp