MCPcopy Index your code
hub / github.com/python/cpython / _determine_linux_fastcopy_blocksize

Function _determine_linux_fastcopy_blocksize

Lib/shutil.py:118–135  ·  view source on GitHub ↗

Determine blocksize for fastcopying on Linux. Hopefully the whole file will be copied in a single call. The copying itself should be performed in a loop 'till EOF is reached (0 return) so a blocksize smaller or bigger than the actual file size should not make any difference, also in

(infd)

Source from the content-addressed store, hash-verified

116 raise err from None
117
118def _determine_linux_fastcopy_blocksize(infd):
119 """Determine blocksize for fastcopying on Linux.
120
121 Hopefully the whole file will be copied in a single call.
122 The copying itself should be performed in a loop 'till EOF is
123 reached (0 return) so a blocksize smaller or bigger than the actual
124 file size should not make any difference, also in case the file
125 content changes while being copied.
126 """
127 try:
128 blocksize = max(os.fstat(infd).st_size, 2 ** 23) # min 8 MiB
129 except OSError:
130 blocksize = 2 ** 27 # 128 MiB
131 # On 32-bit architectures truncate to 1 GiB to avoid OverflowError,
132 # see gh-82500.
133 if sys.maxsize < 2 ** 32:
134 blocksize = min(blocksize, 2 ** 30)
135 return blocksize
136
137def _fastcopy_copy_file_range(fsrc, fdst):
138 """Copy data from one regular mmap-like fd to another by using

Callers 2

_fastcopy_sendfileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…