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 commented on 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 commented on Jan 23, 2026
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.