Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
GH-134160: Prefer multi-phase initialisation in docs#134764
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
base:main
Are you sure you want to change the base?
Conversation
An alternate way to specify extensions is to request "multi-phase initialization". | ||
The preferred method to specify extensions is to request "multi-phase initialization". | ||
Extension modules created this way behave more like Python modules: the | ||
initialization is split between the *creation phase*, when the module object | ||
is created, and the *execution phase*, when it is populated. | ||
The distinction is similar to the :py:meth:`!__new__` and :py:meth:`!__init__` methods | ||
of classes. | ||
Unlike modules created using single-phase initialization, these modules are not | ||
singletons: if the *sys.modules* entry is removed and the module is re-imported, | ||
a new module object is created, and the old module is subject to normal garbage | ||
collection -- as with Python modules. | ||
Unlike modules created usingthe legacysingle-phase initialization mechanism, | ||
these modules are notsingletons: if the *sys.modules* entry is removed and | ||
the module is re-imported,a new module object is created, and the old module | ||
is subject to normal garbagecollection -- as with Python modules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think this shouldn't be a comparison. If we're calling single-phase “legacy” (which finallyseems to be the cunsensus), then this section should describe what modulesare, and the single-phase section should describe the eldritch weirdness of that method.
Should I try to reword it that way? (I'd like to avoid merge conflicts.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There is existing mention of single-phase as 'legacy', though admittedly in a niche location:https://docs.python.org/3/c-api/init.html#c.PyInterpreterConfig.check_multi_interp_extensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Should I try to reword it that way? (I'd like to avoid merge conflicts.)
@encukou feel free to push to this branch.
Uh oh!
There was an error while loading.Please reload this page.
Follows from#134296.
A
📚 Documentation preview 📚:https://cpython-previews--134764.org.readthedocs.build/