This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.snow
Recipients eric.snow, vstinner
Date 2022-03-08.19:55:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1646769353.37.0.654119794325.issue46964@roundup.psfhosted.org>
In-reply-to
Content
tl;dr let's move PyInterpreterState.config to _PyRuntimeState.config.

Historically the runtime has been initialized using Py_Initialize().  PEP 587 added Py_InitializeFromConfig(), which takes a PyConfig and allows all sorts of customization of the runtime.  This is valuable for embedders (and benefits core development too).

During runtime initialization the given config is copied and stored internally on the main interpreter.  Once initialization completes, the config is no longer modified.  The config values are then used in a variety of places during execution.  If a new interpreter is created then the config from the current (or main) interpreter are copied into it.

Note the following:

* the config is never modified
* there is no public API for getting the config or changing it
* there is no API for creating an interpreter with a different config
* the fact that the config is stored on the interpreter is an internal detail and not documented (nor discussed in PEP 587)

Consequently, PyConfig really is the global runtime config.  Yet we are storing a copy of it on each interpreter.  Doing so unnecessarily adds extra complexity (and, when multiple interpreters are used, extra CPU usage and extra memory usage).

So I propose that we move the config to _PyRuntimeState.  The change isn't big nor all that complex.  Note that actually there is one field that can differ between interpreters: PyConfig._isolated_interpreter (set in _Py_NewInterpreter()).  We can move that one field to a new per-interpreter config struct.
History
Date User Action Args
2022-03-08 19:55:53eric.snowsetrecipients: + eric.snow, vstinner
2022-03-08 19:55:53eric.snowsetmessageid: <1646769353.37.0.654119794325.issue46964@roundup.psfhosted.org>
2022-03-08 19:55:53eric.snowlinkissue46964 messages
2022-03-08 19:55:53eric.snowcreate