https://github.com/python/cpython/commit/43c3438a2a31cef152e5fa1172983b4d3e4d8a58
commit: 43c3438a2a31cef152e5fa1172983b4d3e4d8a58
branch: main
author: Lukas Geiger <[email protected]>
committer: emmatyping <[email protected]>
date: 2026-05-19T00:48:41Z
summary:
gh-141968: Use `take_bytes` to remove copy in `_pyio.BytesIO.read()` (#149850)
files:
M Lib/_pyio.py
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 1b5b75ef566a32..9c7faa26bb4bd4 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -941,7 +941,7 @@ def read(self, size=-1):
newpos = min(len(self._buffer), self._pos + size)
b = self._buffer[self._pos : newpos]
self._pos = newpos
- return bytes(b)
+ return b.take_bytes()
def read1(self, size=-1):
"""This is the same as read.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]