Skip to content

gh-129005: Avoid copy in _pyio.FileIO.readinto#129006

Closed
cmaloney wants to merge 8 commits intopython:mainfrom
cmaloney:cmaloney/pyio_readinto
Closed

gh-129005: Avoid copy in _pyio.FileIO.readinto#129006
cmaloney wants to merge 8 commits intopython:mainfrom
cmaloney:cmaloney/pyio_readinto

Conversation

@cmaloney
Copy link
Contributor

@cmaloney cmaloney commented Jan 18, 2025

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

PR of readinto first as it is a lot smaller diff than the readall code but has the core os.read -> os.readv change. In main how the buffer is expanded between _io (new_buffersize) and _pyio (inline in read()) should get lined up.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants