Skip to content

Conversation

@cmaloney
Copy link
Contributor

@cmaloneycmaloney commented Jan 26, 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.readinto.

os.readinto uses PyObject_GetBuffer to make sure the passed in buffer is writeable and bytes-like, drop the manual check.

`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.readinto`. `os.readinto` uses `PyObject_GetBuffer` to make sure the passed in buffer is writeable and bytes-like, drop the manual check.
Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vstinnervstinner merged commit 180ee43 into python:mainJan 28, 2025
44 checks passed
@vstinner
Copy link
Member

Merged, thank you.

@cmaloneycmaloney deleted the cmaloney/pyio_to_os_readinto branch January 28, 2025 17:34
Sign up for freeto 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

@cmaloney@vstinner