Skip to content

Commit d63efa1

Browse files
committed
Reenable sendfile fast-copy syscall on Solaris
1 parent b11a951 commit d63efa1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Doc/library/shutil.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ the use of userspace buffers in Python as in "``outfd.write(infd.read())``".
453453

454454
On macOS `fcopyfile`_ is used to copy the file content (not metadata).
455455

456-
On Linux :func:`os.sendfile` is used.
456+
On Linux and Solaris :func:`os.sendfile` is used.
457457

458458
On Windows :func:`shutil.copyfile` uses a bigger default buffer size (1 MiB
459459
instead of 64 KiB) and a :func:`memoryview`-based variant of
@@ -465,6 +465,9 @@ file then shutil will silently fallback on using less efficient
465465

466466
.. versionchanged:: 3.8
467467

468+
.. versionchanged:: 3.10
469+
Solaris now uses :func:`os.sendfile` rather than no fast-copy operation.
470+
468471
.. _shutil-copytree-example:
469472

470473
copytree example

Lib/shutil.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 64 * 1024
4343
# This should never be removed, see rationale in:
4444
# https://bugs.python.org/issue43743#msg393429
45-
_USE_CP_SENDFILE = hasattr(os, "sendfile") and sys.platform.startswith("linux")
45+
_USE_CP_SENDFILE = hasattr(os, "sendfile") and sys.platform.startswith(("linux", "sunos"))
4646
_HAS_FCOPYFILE = posix and hasattr(posix, "_fcopyfile") # macOS
4747

4848
# CMD defaults in Windows 10
@@ -106,7 +106,7 @@ def _fastcopy_fcopyfile(fsrc, fdst, flags):
106106
def _fastcopy_sendfile(fsrc, fdst):
107107
"""Copy data from one regular mmap-like fd to another by using
108108
high-performance sendfile(2) syscall.
109-
This should work on Linux >= 2.6.33 only.
109+
This should work on Linux >= 2.6.33 and Solaris only.
110110
"""
111111
# Note: copyfileobj() is left alone in order to not introduce any
112112
# unexpected breakage. Possible risks by using zero-copy calls
@@ -261,7 +261,7 @@ def copyfile(src, dst, *, follow_symlinks=True):
261261
return dst
262262
except _GiveupOnFastCopy:
263263
pass
264-
# Linux
264+
# Linux / Solaris
265265
elif _USE_CP_SENDFILE:
266266
try:
267267
_fastcopy_sendfile(fsrc, fdst)

0 commit comments

Comments
 (0)