Proposal: Officially Deprecate Support for Legacy (Single-Phase Init) Extension Modules

I can give an (expanded) interpretation to the section:

“Multi-phase init modules are not expected to support subinterpreters until full isolation is achieved.”

In that case, the multiple-interpreters support sounds like a non-default option at least when introducing. I’d prefer the reconsideration if possible.

Following up on NumPy, @AA-Turner has been busy and at least has an outline towards converting NumPy’s extension modules to multi-phase init! :tada:

7 Likes

I’ve also just seen that SWIG has a draft PR to support multi-phase at Python: Use multi-phase initialization by jschueller · Pull Request #3184 · swig/swig · GitHub (by @jschueller)

A

1 Like

The section starts with:

Extensions using the new initialization scheme are expected to support subinterpreters and multiple Py_Initialize/Py_Finalize cycles correctly, avoiding the issues mentioned in Python documentation.

I’m not sure how you can interpret that as multi-phase modules not being expected to support subinterpreters.

Anyway, the PEP is history; current docs have been saying this since 3.5:

All modules created using multi-phase initialization are expected to support sub-interpreters. Making sure multiple modules are independent is typically enough to achieve this.

1 Like

I opened PR #134775 to give more info here.

1 Like

For the record: PR #134764 proposes to document single-phase init as legacy.
I think that matches the consensus here, but, I’m obviously biased.

The only reason to use single-phase init should be backwards compatibility. It can be a very strong reason, of course.

8 Likes