Content-Length: 512317 | pFad | https://github.com/python/cpython/pull/31771

04 bpo-46964: Move PyInterpreterState.config to _PyRuntimeState.config by ericsnowcurrently · Pull Request #31771 · python/cpython · GitHub
Skip to content

bpo-46964: Move PyInterpreterState.config to _PyRuntimeState.config#31771

Draft
ericsnowcurrently wants to merge 12 commits intopython:mainfrom
ericsnowcurrently:runtime-config
Draft

bpo-46964: Move PyInterpreterState.config to _PyRuntimeState.config#31771
ericsnowcurrently wants to merge 12 commits intopython:mainfrom
ericsnowcurrently:runtime-config

Conversation

@ericsnowcurrently
Copy link
Member

@ericsnowcurrently ericsnowcurrently commented Mar 8, 2022

As part of this, we also move PyConfig._isolated_interpreter to a new _PyInterpreterConfig struct and split it up into more granular settings. We also change some of the private API names to explicitly indicate they relate to global config.

https://bugs.python.org/issue46964

/* Allow the creation of threads. */
unsigned int allow_threading:1;
/* Padding to ensure byte alignment. */
unsigned int :5;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

structs must be at least byte aligned, so this isn't strictly necessary.

PyInterpreterState *interp = _PyInterpreterState_GET();
/* pymain_run_stdin() modify the config */
PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp);
PyConfig *config = (PyConfig*)_PyInterpreterState_GetGlobalConfig(interp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the cast?

{
/* Update the stdio encoding to the normalized Python codec name. */
PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp);
PyConfig *config = (PyConfig*)_PyInterpreterState_GetGlobalConfig(interp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the cast?

For example, replace "ANSI_X3.4-1968" (locale encoding) with "ascii"
(Python codec name). */
PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp);
PyConfig *config = (PyConfig*)_PyInterpreterState_GetGlobalConfig(interp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

{
PyInterpreterState *interp = _PyInterpreterState_GET();
PyConfig *config = (PyConfig *)_PyInterpreterState_GetConfig(interp);
PyConfig *config = (PyConfig *)_PyInterpreterState_GetGlobalConfig(interp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

void
_PyInterpreterConfig_Clear(_PyInterpreterConfig *config)
{
*config = (_PyInterpreterConfig){};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs struct?

}

status = _PyConfig_Copy(&tstate->interp->config, &config);
status = _PyConfig_Copy(&tstate->interp->runtime->config, &config);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a very convoluted way to get a static object

@kumaraditya303 kumaraditya303 removed their request for review November 30, 2022 16:22
@encukou
Copy link
Member

encukou commented Mar 19, 2024

_PyInterpreterConfig has been added in #98609.
@ericsnowcurrently, do you have any more plans with this PR?

@ericsnowcurrently
Copy link
Member Author

Yeah, there are a few things that I need to follow up on here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/python/cpython/pull/31771

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy