File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -412,6 +412,10 @@ On macOS `fcopyfile`_ is used to copy the file content (not metadata).
412
412
On Linux, Solaris and other POSIX platforms where :func: `os.sendfile ` supports
413
413
copies between 2 regular file descriptors :func: `os.sendfile ` is used.
414
414
415
+ On Windows :func: `shutil.copyfile ` uses a bigger default buffer size (1 MiB
416
+ instead of 16 KiB) and if file size >= 128 MiB a :func: `memoryview `-based
417
+ variant of :func: `shutil.copyfileobj ` is used.
418
+
415
419
If the fast-copy operation fails and no data was written in the destination
416
420
file then shutil will silently fallback on using less efficient
417
421
:func: `copyfileobj ` function internally.
Original file line number Diff line number Diff line change @@ -100,8 +100,9 @@ Optimizations
100
100
"fast-copy" means that the copying operation occurs within the kernel,
101
101
avoiding the use of userspace buffers in Python as in
102
102
"``outfd.write(infd.read()) ``".
103
- Also, :func: `shutil.copyfile ` default buffer size on Windows was increased
104
- from 16 KiB to 1 MiB.
103
+ On Windows :func: `shutil.copyfile ` default buffer size was increased
104
+ from 16 KiB to 1 MiB and a faster implementation of :func: `shutil.copyfileobj `
105
+ is used for files bigger than 128 MiB.
105
106
The speedup for copying a 512 MiB file within the same partition is about
106
107
+26% on Linux, +50% on macOS and +40% on Windows. Also, much less CPU cycles
107
108
are consumed.
Original file line number Diff line number Diff line change 2
2
:func: `shutil.copytree ` and :func: `shutil.move ` use platform-specific
3
3
fast-copy syscalls on Linux, Solaris and macOS in order to copy the file
4
4
more efficiently.
5
- Also, :func: `shutil.copyfile ` default buffer size on Windows was increased
6
- from 16KiB to 1MiB. The speedup for copying a 512MiB file is about +26% on
7
- Linux, +50% on macOS and +40% on Windows. Also, much less CPU cycles are
8
- consumed (Contributed by Giampaolo Rodola' in :issue: `25427 `.)
5
+ On Windows :func: `shutil.copyfile ` uses a bigger default buffer size (1 MiB
6
+ instead of 16 KiB) and if file size >= 128 MiB a :func: `memoryview `-based
7
+ variant of :func: `shutil.copyfileobj ` is used.
8
+ The speedup for copying a 512MiB file is about +26% on Linux, +50% on macOS and
9
+ +40% on Windows. Also, much less CPU cycles are consumed.
10
+ (Contributed by Giampaolo Rodola' in :issue: `25427 `.)
You can’t perform that action at this time.
0 commit comments