Repository navigation
[GR-81913] Honor Python optimization flags and environment settings. - #1333
Merged
Merged
Conversation
Signed-off-by: Fabio Niephaus <fabio.niephaus@oracle.com>
Signed-off-by: Fabio Niephaus <fabio.niephaus@oracle.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 The launcher accepts -O and -OO but ignores them and never reads PYTHONOPTIMIZE. The compiler supports optimization levels, but its process default is boolean, and file/stdin and interactive execution force level 0.
Add the integer engine option python.OptimizationLevel and wire repeated/clustered -O flags and PYTHONOPTIMIZE to it. Match CPython's environment parsing and maximum-of-flags/environment behavior, respecting -E and -I. Preserve the stable boolean PythonOptimizeFlag option as an alias for level 1.
Use the resolved level for sys.flags.optimize, builtins.debug, and default compilation, including files, stdin, interactive/inline parsing, compile(), exec(), eval(), and optimized ASTs. Explicit compile/source optimization levels continue to override the context default. Document the embedding option and update launcher help.
Add nine Python regression methods covering flags, environment precedence, assertions, docstrings, execution modes, dynamic compilation and import cache levels. Extend embedding tests for source overrides and code-cache separation between contexts sharing an engine.
Validation on Linux AArch64 with JDK 25: