Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-phase module initialisation (PEP 489) #1715

Closed
scoder opened this issue May 25, 2017 · 3 comments
Closed

Multi-phase module initialisation (PEP 489) #1715

scoder opened this issue May 25, 2017 · 3 comments

Comments

@scoder
Copy link
Contributor

scoder commented May 25, 2017

CPython 3.5 introduced a new module initialisation scheme in multiple phases:
https://www.python.org/dev/peps/pep-0489/

This improves the support for extension module reloading and could also allow running extension modules as main module (python -m) in the future (probably Py3.7).

Worth implementing. It requires splitting up the generate_module_init_func() method in https://github.com/cython/cython/blob/master/Cython/Compiler/ModuleNode.py to generate separate functions for the separate phases, and then also to find a compatible fallback way to execute them in older Python versions.

The proposed CPython support for runnable extension modules is tracked here: https://bugs.python.org/issue30403

@scoder
Copy link
Contributor Author

scoder commented Jul 22, 2017

Implemented in #1794

@scoder
Copy link
Contributor Author

scoder commented Oct 29, 2017

Reopening since the implementation in 0.27.0 is not complete and was disabled in 0.27.1. It requires proper reloading support, which is not trivial.

@scoder
Copy link
Contributor Author

scoder commented Sep 15, 2018

The implementation in the latest master branch should be safer now. It does not allow module reloading nor does it support subinterpreters. In fact, it detects subinterpreters and prevents a reload in a different one than the first import. A reload in the same interpreter simply returns the existing module.

@scoder scoder closed this as completed Sep 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant