From a61f7320084ba598c3919c91b5cfdd590dd8a961 Mon Sep 17 00:00:00 2001 From: Lukas Geiger Date: Thu, 14 May 2026 23:37:22 +0100 Subject: [PATCH] gh-141968: Use `take_bytes` to remove copy in `_pyio.BytesIO.read()` --- Lib/_pyio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 3306c8a274760b..00902837fb283e 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.