diff -r 8d3932671e48 Lib/shutil.py --- a/Lib/shutil.py Wed Oct 28 21:45:01 2015 +0200 +++ b/Lib/shutil.py Thu Oct 29 00:38:08 2015 +0100 @@ -113,7 +113,16 @@ else: with open(src, 'rb') as fsrc: with open(dst, 'wb') as fdst: - copyfileobj(fsrc, fdst) + if hasattr(os, 'sendfile'): + # Prefer os.sendfile if available for performance + max_bcount = 2 ** 31 - 1 + bcount = max_bcount + offset = 0 + while bcount > 0: + bcount = os.sendfile(fdst.fileno(), fsrc.fileno(), offset, max_bcount) + offset += bcount + else: + copyfileobj(fsrc, fdst) return dst def copymode(src, dst, *, follow_symlinks=True):