Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
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
18 changes: 14 additions & 4 deletions Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1695,10 +1695,20 @@ def readall(self):
def readinto(self, b):
"""Same as RawIOBase.readinto()."""
m = memoryview(b).cast('B')
data = self.read(len(m))
n = len(data)
m[:n] = data
return n
self._checkClosed()
self._checkReadable()
try:
if hasattr(os, 'readv'):
return os.readv(self._fd, (m, ))

data = os.read(self._fd, len(m))
n = len(data)
m[:n] = data
return n
except BlockingIOError:
return None



def write(self, b):
"""Write bytes b to file, return number written.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change ``_pyio.FileIO.readinto`` to use :func:`os.readv` avoiding a copy that was present when using :func:`os.read` on platforms with :func:`os.readv`
Loading