-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
gh-60107: Remove a copy from RawIOBase.read #141532
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
base: main
Are you sure you want to change the base?
Conversation
If the underlying I/O class keeps a reference to the memory raise BufferError.
| } | ||
| return res; | ||
| } | ||
| res = PyObject_CallMethod(b, "take_bytes", NULL); |
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.
@vstinner : Not sure how common this "resize/discard then take_bytes" is going to be; might make sense to change to take_bytes(n=None, /, *, discard=False)
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.
for now planning to keep that in back pocket until need many ways (ba.resize(n) or del ba[:n] gives the same capability)
vstinner
left a comment
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.
Can you also update RawIOBase.read() in the _pyio module?
|
Have that in #141539 which does all the cases |
If the underlying I/O class keeps a reference to the memory raise
BufferError.Uses gh-139871 to implement.
--
If want to maintain closer compatibility when a
BufferErroroccurs can fall back to a copy (copying is as safe as the original code). I have a slight preference to erroring as I think keeping a reference to the memory is uncommon (and probably unintended).bytearraytobytesin rawiobase_read() implementation #60107