Skip to content

Conversation

@savannahostrowski
Copy link
Member

@savannahostrowski savannahostrowski commented Dec 4, 2025

bm_subparsers benchmark (1000 optional arguments, 10 iterations):

Version Time
3.13 0.246s
3.14 0.934s
3.15 (main) 0.883s
3.15 (with fix) 0.158s

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%)

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@savannahostrowski savannahostrowski enabled auto-merge (squash) December 5, 2025 16:20
@savannahostrowski savannahostrowski merged commit 4085ff7 into python:main Dec 5, 2025
46 checks passed
@miss-islington-app
Copy link

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>
@bedevere-app
Copy link

bedevere-app bot commented Dec 5, 2025

GH-142313 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Dec 5, 2025
savannahostrowski added a commit that referenced this pull request Dec 5, 2025
GH-142268) (#142313)

GH-142267: Cache formatter to avoid repeated `_set_color` calls (GH-142268)
(cherry picked from commit 4085ff7)

Co-authored-by: Savannah Ostrowski <savannah@python.org>
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants