← 返回首页
Allow efficient read access to PyConfig options · Issue #99872 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Allow efficient read access to PyConfig options #99872

New issue
New issue

Description

Documentation

The documentation seems to be geared towards embedding scenarios and modifying the configuration, and I couldn't find an example for simply reading a PyConfig field.

PEP 587 seems similarly unhelpful.

Looking through the CPython sources, it appears that what I want to do is this:

PyThreadState *tstate = _PyThreadState_GET(); PyConfig* config = &tstate->interp->config; int optimize_flag = config->optimization_level; // formerly known as Py_OptimizeFlag

I'm pretty sure that this is not the official API way to do it, but it's unclear to me what the right way is, given that PyInterpreterState is an opaque struct and the previously simple access to Py_OptimizeFlag has been deprecated as of Py3.12.

Also, it's unclear what way of access should be used in the limited API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    • Open in GitHub Copilot app

    Footer

    © 2026 GitHub, Inc.