Performance: don't use f-strings in debug prints#606
Merged
niknetniko merged 1 commit intomasterfrom Jan 24, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes debug logging performance by converting f-string formatting to lazy string formatting. The change prevents string construction when debug logging is disabled, resulting in measurable performance improvements (up to 5% reduction in total run time).
Changes:
- Replaced f-string formatting in debug log statements with printf-style
%splaceholders - Moved variables from inline f-string expressions to separate logger arguments
- Applied changes consistently across 10 files covering parsing, execution, evaluation, and configuration modules
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tested/parsing.py | Converted 4 debug log statements in type structure functions |
| tested/oracles/programmed.py | Converted 2 debug log statements including multi-line oracle parameter logging |
| tested/judge/utils.py | Converted 2 debug log statements for file copying operations |
| tested/judge/execution.py | Converted 4 debug log statements for execution, dependencies, and file operations |
| tested/judge/evaluation.py | Converted 1 debug log statement for testcase evaluation |
| tested/judge/core.py | Converted 5 debug log statements for worker execution and file generation |
| tested/judge/compilation.py | Converted 1 debug log statement for compilation dependencies |
| tested/judge/collector.py | Converted 3 debug log statements for command and stack management |
| tested/internationalization/init.py | Converted 1 debug log statement for locale changes |
| tested/configs.py | Converted 2 multi-line debug log statements for language detection |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
niknetniko
approved these changes
Jan 24, 2026
Member
niknetniko
left a comment
There was a problem hiding this comment.
Nice speed up for no changes at all.
niknetniko
approved these changes
Jan 24, 2026
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.
Many of the debug prints contained f-strings. While these are easy to read, the string is created even if the logger never needs the actual string because of the debug level. Switching to lazy string formatting saves some work and garbage collection if debugging is not enabled.
Unexpectedly, performance gains are measurable and up to 5% when measuring the total run time of a single exercise (21.6s -> 20.5s, average over 10 runs).