FR: Allow private runtime config to enable extending without breaking the `PyConfig` ABI

I will need to set some of the global runtime variables we had after the interpreter was initialized. Specifically, I’m currently setting these variables:

  • optimize level
  • verbose level
  • debug level
  • inspect flag
  • don’t write bytecode flag

(and I’d like to expand this list to all variables that can be set via the command line)

This has been working just fine up until 3.11, when Victor removed support for this. The global variables still exist in 3.11, but setting them after interpreter initialization no longer has any effect, so I will have to dig deeper and ideally would like to use proper C APIs for this.

Just to add more context: eGenix PyRun is a version of the CPython interpreter which freezes most of the stdlib into a single binary on Unix using the freeze tool. Because the frozen binary entry point does not run the usual command line parsing, I am emulating a lot of the startup logic in Python (which actually makes the whole thing much easier to understand and maintain, IMHO, much like importlib replaced loads of C code). I’m currently preparing a version to put up on Github for easier access. It’s been open source ever since I started the project, but was part of our internal repo.

1 Like