You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Optimizer calls getenv on every optimization run #116772
The optimizer currently calls getenv during every optimization attempt. This has a small, but statistically significant 0.5% impact on performance. Do we need to do this each time, or could we read it to a flag during initialization?
IMHO options should be processed using the PyConfig interface, that way all configuration stays in a central place and it is easier for embedders to change this setting. Also: With the current code there's no way to enable this option when using python -E.
This issue seems to have been resolved by #144082, which moved PYTHON_UOPS_OPTIMIZE to the _PyOptimizationConfig. The environment variable is now read once during interpreter initialization in pystate.c and cached in interp->opt_config.uops_optimize_enabled so we aren't calling getenv() for this flag during optimization runs.
Activity
ronaldoussoren commentedon Mar 16, 2024
IMHO options should be processed using the PyConfig interface, that way all configuration stays in a central place and it is easier for embedders to change this setting. Also: With the current code there's no way to enable this option when using
python -E.savannahostrowski commentedon Jan 23, 2026
This issue seems to have been resolved by #144082, which moved
PYTHON_UOPS_OPTIMIZEto the_PyOptimizationConfig. The environment variable is now read once during interpreter initialization inpystate.cand cached ininterp->opt_config.uops_optimize_enabledso we aren't callinggetenv()for this flag during optimization runs.