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

Function _get_copy_blocksize

Lib/pathlib/_os.py:23–39  ·  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

21
22
23def _get_copy_blocksize(infd):
24 """Determine blocksize for fastcopying on Linux.
25 Hopefully the whole file will be copied in a single call.
26 The copying itself should be performed in a loop 'till EOF is
27 reached (0 return) so a blocksize smaller or bigger than the actual
28 file size should not make any difference, also in case the file
29 content changes while being copied.
30 """
31 try:
32 blocksize = max(os.fstat(infd).st_size, 2 ** 23) # min 8 MiB
33 except OSError:
34 blocksize = 2 ** 27 # 128 MiB
35 # On 32-bit architectures truncate to 1 GiB to avoid OverflowError,
36 # see gh-82500.
37 if sys.maxsize < 2 ** 32:
38 blocksize = min(blocksize, 2 ** 30)
39 return blocksize
40
41
42if fcntl and hasattr(fcntl, 'FICLONE'):

Callers 2

_copy_file_rangeFunction · 0.85
_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…