mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-36103: change default buffer size of shutil.copyfileobj() (GH-12115)
It is changed from 16KiB to 64KiB. The previous default value is used since 1990. coreutils chose 128 KiB as minimum buffer size for block device I/O. But shutil.copyfileobj() can be used for non block devices. So I choose more conservative value. As my quick benchmark, performance difference between 64KiB and 128 KiB is up to ~5%. On the other hand, performance difference between 32 KiB and 64 KiB can be more than 10% when file is fully buffered. This is why 64 KiB is rational value.
This commit is contained in:
parent
bcfa450f21
commit
4f19030618
3 changed files with 5 additions and 2 deletions
|
@ -49,7 +49,7 @@ if os.name == 'posix':
|
|||
elif _WINDOWS:
|
||||
import nt
|
||||
|
||||
COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 16 * 1024
|
||||
COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 64 * 1024
|
||||
_HAS_SENDFILE = posix and hasattr(os, "sendfile")
|
||||
_HAS_FCOPYFILE = posix and hasattr(posix, "_fcopyfile") # macOS
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue