Skip to content

Avoid repeated RHS splits for flat subscript chains - #5305

Closed
aryansk wants to merge 1 commit into
psf:mainfrom
aryansk:codex/black-5270
Closed

aryansk wants to merge 1 commit into
psf:mainfrom
aryansk:codex/black-5270

Conversation

@aryansk

@aryansk aryansk commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #5270

Summary

  • Add a fast path for flat, comment-free subscript chains that selects the existing RHS split candidate in one scan.
  • Preserve the current formatting output while avoiding repeated construction of rejected split candidates.
  • Add exact-output and split-search regression tests.

Tests

  • Flat subscript regression and split-search tests: 2 passed.
  • tests/test_trans.py: 1 passed.
  • Output parity was checked against the pre-change formatter for representative subscript chains.

This PR was prepared with AI assistance and the implementation and test results were reviewed locally.

@github-actions

Copy link
Copy Markdown
Contributor

diff-shades results comparing this PR (3bff8ca) to main (74371e2):

--preview style: no changes

--stable style: no changes


What is this? | Workflow run | diff-shades documentation

@cobaltt7

Copy link
Copy Markdown
Collaborator

Is there a reason why this is a draft PR, or is it ready for review?

@cobaltt7

cobaltt7 commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

@aryansk Is this being updated?

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.

Quadratic formatting time for chains of subscripts (7s for one 160-subscript line; attribute/call chains stay linear)

2 participants