[Python-Dev] New _Py_InitializeFromConfig() function (PEP 432)

Nick Coghlan ncoghlan at gmail.com
Sat Aug 4 03:55:03 EDT 2018

On 1 August 2018 at 08:14, Victor Stinner <vstinner at redhat.com> wrote:
> Hi,
> I finished my work on the _PyCoreConfig structure: it's a C structure
> in Include/pystate.h which has many fields used to configure Python
> initialization. In Python 3.6 and older, these parameters were scatted
> around the code, and it was hard to get an exhaustive list of it.
> This work is linked to the Nick Coghlan's PEP 432 "Restructuring the
> CPython startup sequence":
> https://www.python.org/dev/peps/pep-0432/
> Right now, the new API is still private. Nick Coghlan splitted the
> initialization in two parts: "core" and "main". I'm not sure that this
> split is needed.

It is, because one of the aims is to make it clear when frozen
bytecode (ala importlib) and other builtin modules can start to be
used as part of the configuration process. That point is when the core
configuration completes. By contrast, main interpreter configuration
is only complete when you have full filesystem access as well
(including external imports).

That separation also means that an embedding application can choose
*not* to proceed to the second step, and thus limit imports to the
modules built in to the application.

> We should see what to do, but it would be nice to
> make the _PyCoreConfig API public! IMHO it's way better than the old
> way to configuration Python initialization.

Step 1 will be to bring PEP 432 up to date with what actually happened
- we learned a lot from your and Eric's efforts in actually
implementing the draft design as a private API, but the current PEP
still reflects the original design concept.

Thanks for all your work on this! It's exciting to see it finally
coming to fruition :)


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list