Skip to content

GH-90117: Check for list and tuple before MappingView in pprint #135779

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Jun 21, 2025

GH-30135 added an expensive ABC subclass check for an uncommon case (MappingView) before fast subclass checks for 2 common cases (list and tuple), resulting in a ~10% performance regression for our pprint benchmarks. There's also some evidence that this may have also made our PGO profile worse on some builds, since test_pprint is part of the profiling task (so we're spending a good chunk of that time hitting the newly-added ABC subclass-checking machinery).

This just switches the order of the branches so the cheap, common case is checked before the expensive, uncommon one.

@brandtbucher brandtbucher requested a review from gpshead June 21, 2025 00:12
@brandtbucher brandtbucher self-assigned this Jun 21, 2025
@brandtbucher brandtbucher added performance Performance or resource usage stdlib Python modules in the Lib dir labels Jun 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review performance Performance or resource usage stdlib Python modules in the Lib dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant