MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _copyfileobj_readinto

Function _copyfileobj_readinto

tools/python-3.11.9-amd64/Lib/shutil.py:170–187  ·  view source on GitHub ↗

readinto()/memoryview() based variant of copyfileobj(). *fsrc* must support readinto() method and both files must be open in binary mode.

(fsrc, fdst, length=COPY_BUFSIZE)

Source from the content-addressed store, hash-verified

168 offset += sent
169
170def _copyfileobj_readinto(fsrc, fdst, length=COPY_BUFSIZE):
171 """readinto()/memoryview() based variant of copyfileobj().
172 *fsrc* must support readinto() method and both files must be
173 open in binary mode.
174 """
175 # Localize variable access to minimize overhead.
176 fsrc_readinto = fsrc.readinto
177 fdst_write = fdst.write
178 with memoryview(bytearray(length)) as mv:
179 while True:
180 n = fsrc_readinto(mv)
181 if not n:
182 break
183 elif n < length:
184 with mv[:n] as smv:
185 fdst.write(smv)
186 else:
187 fdst_write(mv)
188
189def copyfileobj(fsrc, fdst, length=0):
190 """copy data from file-like object fsrc to file-like object fdst"""

Callers 1

copyfileFunction · 0.85

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected