Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,9 @@ 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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove an unnecessary copy when ``_pyio.BufferedReader.read`` is called to
read all data from a file and has no data already in buffer.
Loading