Repository navigation
Conversation
Replaces BufferedWriter's bytearray + _write_lock with a _Nibbler buffer manager built around _Morsel work units. Adds FileIO._writev so the nibbler can issue a single writev(2) for multi-buffer flushes when available, falling back to coalesce+write otherwise. The Nibbler holds its lock end-to-end across raw I/O, matching the pre-existing cross-thread write ordering guarantee. A future two-lock split (short buffer lock + I/O lock) is sketched in the class docstring as the intended path for releasing the I/O lock once profiling justifies it. Also restores f.close() in BufferSizeTest.try_one's nested finally and skips test_slow_close_from_thread pending a way to validate pythongh-76157 / pythongh-31976 that does not assume the old lock-across-I/O behavior. See: https://discuss.python.org/t/reworking-buffered-i-o-in-cpython/90019 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
One of the forms I built of this. Focuses on BufferedWriter. Iterating with AI / not all comments as clean as I might like and definitely more refactoring to do.