-
Notifications
You must be signed in to change notification settings - Fork 55
feat[next]: warn in case python is run without -O for non-embedded #2538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -569,6 +569,14 @@ def _compile_variant( | |||||
| # key computed here | ||||||
| call_key: CompiledProgramsKey | None = None, | ||||||
| ) -> None: | ||||||
| if __debug__: | ||||||
|
||||||
| warnings.warn( | ||||||
| "Python is not running in optimized mode, which may impact performance when using a" | ||||||
| " compiled backend. Consider running with `python -O` or setting the environment" | ||||||
|
||||||
| " compiled backend. Consider running with `python -O` or setting the environment" | |
| " non-embedded backend. Consider running with `python -O` or setting the environment" |
Outdated
Copilot
AI
Mar 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With stacklevel=2 this warning will typically point at an internal call site in compiled_program.py (e.g., the _compile_variant caller) rather than the public API entry points (Program.__call__ / Program.compile) that users interact with. Consider increasing the stacklevel so the warning location is more actionable (and remains stable across call sites).
| stacklevel=2, | |
| stacklevel=3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@havogt can you check if this suggestion make sense? I don't know by heart right now...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated fix that I sneak in...