From c37b1222fb733f6de0bba6d85014e27b76963d65 Mon Sep 17 00:00:00 2001 From: Cody Maloney Date: Thu, 30 Jan 2025 21:40:19 -0800 Subject: [PATCH] Revert "gh-129005: _pyio.BufferedIO remove copy on readall (#129454)" This reverts commit e1c4ba928852eac0b0e0bded1c314e3e36975286. --- Lib/_pyio.py | 3 --- .../Library/2025-01-29-00-00-01.gh-issue-129005.aV_3O8.rst | 2 -- 2 files changed, 5 deletions(-) delete mode 100644 Misc/NEWS.d/next/Library/2025-01-29-00-00-01.gh-issue-129005.aV_3O8.rst diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 755e0258770891..76a27910da4d5f 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -1062,9 +1062,6 @@ def _read_unlocked(self, n=None): if chunk is None: return buf[pos:] or None else: - # Avoid slice + copy if there is no data in buf - if not buf: - return chunk return buf[pos:] + chunk chunks = [buf[pos:]] # Strip the consumed bytes. current_size = 0 diff --git a/Misc/NEWS.d/next/Library/2025-01-29-00-00-01.gh-issue-129005.aV_3O8.rst b/Misc/NEWS.d/next/Library/2025-01-29-00-00-01.gh-issue-129005.aV_3O8.rst deleted file mode 100644 index 48ee57109be2ff..00000000000000 --- a/Misc/NEWS.d/next/Library/2025-01-29-00-00-01.gh-issue-129005.aV_3O8.rst +++ /dev/null @@ -1,2 +0,0 @@ -:mod:`!_pyio`: Remove an unnecessary copy when ``_pyio.BufferedReader.read()`` -is called to read all data from a file and has no data already in buffer.