Repository navigation
sdk/python: avoid oversized read-all buffers for small files - #7899
Merged
jiefenghuang merged 2 commits intoNov 24, 2026
Merged
jiefenghuang merged 2 commits into
jiefenghuang merged 2 commits into
Conversation
adenzhou1350
requested review from
CaitinChen and
jiefenghuang
as code owners
November 21, 2026 08:20
zxh326
approved these changes
Nov 23, 2026
jiefenghuang
approved these changes
Nov 24, 2026
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.
Problem
f.read()allocates a 4 MiB buffer even for a small file and again to discover EOF. This also affects ordinaryjson.load()through the default buffered text wrapper; it is separate from thereadinto()path fixed in #7865.Change
Use the known remaining file length as an allocation hint, with the normal I/O buffer size as a floor. Keep the 4 MiB ceiling and continue reading until native EOF. Add memory, partial-read and sparse multi-chunk regressions, plus English/Chinese SDK notes.
Validation
23d2a456: original 19 pass/1 memory-regression failure; candidate 20 pass, no errors/skips. Local fixtures used private SQLite/local files, Python 3.12 and a reused libjfs build.pysdk_test.pyand subsequent property tests.git diff --checkpass. Existing SDK CI selects the new tests.AI-assisted source audit and patch/test preparation; results independently executed.