GH-142267: Cache formatter to avoid repeated _set_color calls#142268
Merged
savannahostrowski merged 7 commits intopython:mainfrom Dec 5, 2025
Merged
GH-142267: Cache formatter to avoid repeated _set_color calls#142268savannahostrowski merged 7 commits intopython:mainfrom
_set_color calls#142268savannahostrowski merged 7 commits intopython:mainfrom
Conversation
vstinner
reviewed
Dec 5, 2025
|
Thanks @savannahostrowski for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Dec 5, 2025
…pythonGH-142268) (cherry picked from commit 4085ff7) Co-authored-by: Savannah Ostrowski <savannah@python.org>
|
GH-142313 is a backport of this pull request to the 3.14 branch. |
savannahostrowski
added a commit
that referenced
this pull request
Dec 5, 2025
StanFromIreland
pushed a commit
to StanFromIreland/cpython
that referenced
this pull request
Dec 6, 2025
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.
bm_subparsers benchmark (1000 optional arguments, 10 iterations):
Profiled with Tachyon (
./python.exe -m profiling.sampling --live):Before:
🥇 HelpFormatter._set_color (12.6%) │ 🥈 Mapping.get (5.4%) │ 🥉 can_colorize._safe_getenv (4.1%)After:
🥇 <GC> (8.4%) │ 🥈 bm_subparsers (8.3%) │ 🥉 _ActionsContainer.add_argument (7.3%)