GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing peps.python.org — PEP 547 – Running extension modules using the -m option | peps.python.org
PEP 547 – Running extension modules using the -m option
PEP 547 – Running extension modules using the -m option
Deferral NoticeCython – the most important use case for this PEP and the only explicit one – is not ready for multi-phase initialization yet. It keeps global state in C-level static variables. See discussion at Cython issue 1923. The PEP is deferred until the situation changes. AbstractThis PEP proposes implementation that allows built-in and extension
modules to be executed in the With this, a multi-phase initialization enabled module can be run using following command: $ python3 -m _testmultiphase This is a test module named __main__. MotivationCurrently, extension modules do not support all functionality of
Python source modules.
Specifically, it is not possible to run extension modules as scripts using
Python’s The technical groundwork to make this possible has been done for PEP 489,
and enabling the RationaleExtension modules’ lack of support for the This works well for standard library modules, as building command line interfaces using the C API is cumbersome. However, other users may want to create executable extension modules directly. An important use case is Cython, a Python-like language that compiles to
C extension modules.
Cython is a (near) superset of Python, meaning that compiling a Python module
with Cython will typically not change the module’s functionality, allowing
Cython-specific features to be added gradually.
This PEP will allow Cython extension modules to behave the same as their Python
counterparts when run using the BackgroundPython’s The module specified by For Python source modules, running in another module’s namespace is not
a problem: the code is executed with Since Python 3.5, extension modules can use PEP 489 multi-phase initialization.
In this scenario, the ProposalMulti-phase initialization makes it possible to execute an extension module in
another module’s namespace: if a One complication in this scheme is C-level module state.
Each module has a The implementation must take care that Since the While PEP 489 was designed to make these changes generally possible,
it’s necessary to decouple module discovery, creation, and initialization
steps for extension modules, so that another module can be used instead of
a newly initialized one, and the functionality needs to be added to
SpecificationA new optional method for importlib loaders will be added.
This method will be called The ExtensionFileLoader Changesimportlib’s
The In the single-phase initialization case, In the multi-phase initialization case, the This function raises Backwards CompatibilityThis PEP maintains backwards compatibility.
It only adds new functions, and a new loader method that is added for
a loader that previously did not support running modules as Reference ImplementationThe reference implementation of this PEP is available at GitHub. CopyrightThis document has been placed in the public domain. |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |