bpo-36103: change default buffer size of shutil.copyfileobj() (GH-12115) · python/cpython@4f19030 (original) (raw)

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -424,7 +424,7 @@ On Linux, Solaris and other POSIX platforms where :func:`os.sendfile` supports
424 424 copies between 2 regular file descriptors :func:`os.sendfile` is used.
425 425
426 426 On Windows :func:`shutil.copyfile` uses a bigger default buffer size (1 MiB
427 -instead of 16 KiB) and a :func:`memoryview`-based variant of
427 +instead of 64 KiB) and a :func:`memoryview`-based variant of
428 428 :func:`shutil.copyfileobj` is used.
429 429
430 430 If the fast-copy operation fails and no data was written in the destination
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@
49 49 elif _WINDOWS:
50 50 import nt
51 51
52 -COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 16 * 1024
52 +COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 64 * 1024
53 53 _HAS_SENDFILE = posix and hasattr(os, "sendfile")
54 54 _HAS_FCOPYFILE = posix and hasattr(posix, "_fcopyfile") # macOS
55 55
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1 +Default buffer size used by ``shutil.copyfileobj()`` is changed from 16 KiB
2 +to 64 KiB on non-Windows platform to reduce system call overhead. Contributed
3 +by INADA Naoki.