-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
gh-129005: Avoid copy in _pyio.FileIO.readinto #129006
Conversation
`os.read` allocated and filled a buffer by calling `read(2)`, than that data was copied into the user provied buffer. Read directly into the caller's buffer instead by using `os.readv`. `self.read()` was doing the closed and readable checks so move those into `readinto`
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)
Misc/NEWS.d/next/Library/2025-01-18-15-29-08.gh-issue-129005.mM5dmV.rst
Outdated
Show resolved
Hide resolved
Thanks for the review @tomasr8 ! Going to close this PR while I work on #129205, then will make a new PR which uses that (See: #129005 (comment) for context if desired). Makes the same change simpler / no conditional around |
os.read
allocated and filled a buffer by callingread(2)
, than that data was copied into the user provied buffer. Read directly into the caller's buffer instead by usingos.readv
.self.read()
was doing the closed and readable checks so move those intoreadinto
PR of
readinto
first as it is a lot smaller diff than thereadall
code but has the coreos.read
->os.readv
change. Inmain
how the buffer is expanded between_io
(new_buffersize
) and_pyio
(inline inread()
) should get lined up.