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

gh-134160: Use multi-phase init in documentation examples#134296

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
neonene wants to merge20 commits intopython:main
base:main
Choose a base branch
Loading
fromneonene:multi

Conversation

neonene
Copy link
Contributor

@neoneneneonene commentedMay 19, 2025
edited by github-actionsbot
Loading

ReplacesPyModule_Create() withPyModuleDef_Init().

Static types still remain unchanged in the doc.


📚 Documentation preview 📚:https://cpython-previews--134296.org.readthedocs.build/

@neonene
Copy link
ContributorAuthor

cc@erlend-aasland@encukou Just in case you're interested.

@AA-TurnerAA-Turner changed the titlegh-134160: Docs: Ensure single-phase init is no longer used in examplesgh-134160: Use multi-phase init in documentation examplesMay 21, 2025
@AA-TurnerAA-Turner added the docsDocumentation in the Doc dir labelMay 21, 2025
@AA-TurnerAA-Turner added needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes labelsMay 21, 2025
Comment on lines 254 to 258
static PyModuleDef_Slot emb_module_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};
Copy link
Member

@AA-TurnerAA-TurnerMay 22, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Having done trial conversions of NumPy to multi-phase, I think we should include the relevant PY_VERSION_HEX checks. Both Py_mod_multiple_interpreters and Py_mod_gil were added very recently.

If we agree on adding these checks, we should add them for all relevant PyModuleDef_Slot structs. It is verbose, but aids in the copy-and-paste scenario.

Suggested change
static PyModuleDef_Slot emb_module_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};
static PyModuleDef_Slot emb_module_slots[] = {
#if PY_VERSION_HEX >= 0x030C00F0 // Python 3.12+
// signal that this module can be imported in isolated subinterpreters
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
#endif
#if PY_VERSION_HEX >= 0x030D00F0 // Python 3.13+
// signal that this module supports running without an active GIL
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
#endif
{0, NULL}
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Alternative:

Suggested change
static PyModuleDef_Slot emb_module_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};
static PyModuleDef_Slot emb_module_slots[] = {
#ifdef Py_mod_multiple_interpreters
// signal that this module can be imported in isolated subinterpreters
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
#endif
#ifdef Py_mod_gil
// signal that this module supports running without an active GIL
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
#endif
{0, NULL}
};

neonene reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Canthis PR omit these slots entirely?

IMO, they should be introduced later, after you compile your first module, along with a longer discussion about isolated state & thread safety.

AA-Turner reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Agree better to keep simple.@neonene perhaps remove the gil and interpreter slots from where we've added them in this PR unless they were already present?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Removed, but not all. I can complete.

@AA-Turner
Copy link
Member

Other places to update:

neoneneand others added3 commitsMay 22, 2025 16:05
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
@neonene
Copy link
ContributorAuthor

Other places to update:

I tried, but I conclude thatPyModule_Create() needs to be deprecated.

@neonene
Copy link
ContributorAuthor

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@encukouencukouencukou left review comments

@AA-TurnerAA-TurnerAA-Turner left review comments

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrently

Assignees
No one assigned
Labels
awaiting reviewdocsDocumentation in the Doc dirneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixesskip news
Projects
Status: Todo
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@neonene@AA-Turner@encukou

[8]ページ先頭

©2009-2025 Movatter.jp