Speed up shutil.copyfile by using sendfile system call
pyfastcopy is a simple Python module that monkey patches the shutil.copyfile function of Python standard library to internally use the sendfile system call.
It can provide important performance improvements for large file copy (typically 30-40%). See the performance section for some numbers.
Because shutil.copyfile is used by other fonctions in the shutil module, the following functions also automatically benefit from the performance boost:
If sendfile is not available on your system or fails, the classic, slower chunk file copy is used, so there is no downside to using this module.
For more information, see my proposed patch for Python.
Just import the module:
And then use the patched shutil.copyfile as usual:
The “sendfile“ system call does not exist on Windows, so importing this module will have no effect.
Python Software Foundation License