]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-141968: Use `take_bytes` to remove copy in `_pyio.BytesIO.read()` (#149850)
authorLukas Geiger <lukas.geiger94@gmail.com>
Tue, 19 May 2026 00:48:41 +0000 (01:48 +0100)
committerGitHub <noreply@github.com>
Tue, 19 May 2026 00:48:41 +0000 (00:48 +0000)
Lib/_pyio.py

index 1b5b75ef566a32b01719a97076a1d67aceb10f19..9c7faa26bb4bd44f78b4ba5faea3105af1df1862 100644 (file)
@@ -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.