Skip to content

Avoid redundant seek/read in LineIterator.__next__ - #6366

Open
RudraDudhat2509 wants to merge 2 commits into
aws:masterfrom
RudraDudhat2509:fix/lineiterator-avoid-redundant-seek-read
Open

RudraDudhat2509 wants to merge 2 commits into
aws:masterfrom
RudraDudhat2509:fix/lineiterator-avoid-redundant-seek-read

Conversation

@RudraDudhat2509

@RudraDudhat2509 RudraDudhat2509 commented Sep 30, 2026 •

Copy link
Copy Markdown

Follow-up to #6279, splitting out the non-blocking nit from the AI code review since @rsareddy0329 suggested a separate PR for it.

remainder was re-read via self.buffer.seek(self.read_pos) + self.buffer.read(), but line (already read a few lines above in the same iteration) holds the exact same bytes, since nothing touches the buffer or read_pos between that read and the StopIteration handler. Just returns line directly now, no behavior change.

All 21 tests in test_iterators.py pass, including test_line_iterator_no_trailing_newline_at_end which covers this exact path.

line already holds the trailing remainder read a few lines above, no
need to seek back and read the buffer again for the same bytes.

Follow-up to aws#6279, per Claude's non-blocking review comment and
rsareddy0329's suggestion to split it into a separate PR.

This branch is waiting to be deployed

1 waiting deployment
manual-approval — ad9bc820 Waiting Sep 30, 2026 by rsareddy0329 via wait-for-approval #1879
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.

2 participants