From: Lukas Geiger Date: Tue, 19 May 2026 00:48:41 +0000 (+0100) Subject: gh-141968: Use `take_bytes` to remove copy in `_pyio.BytesIO.read()` (#149850) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43c3438a2a31cef152e5fa1172983b4d3e4d8a58;p=thirdparty%2FPython%2Fcpython.git gh-141968: Use `take_bytes` to remove copy in `_pyio.BytesIO.read()` (#149850) --- diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 1b5b75ef566a..9c7faa26bb4b 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -941,7 +941,7 @@ class BytesIO(BufferedIOBase): 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.