Reflinks (copy-on-write clones) are much faster to create and far more space-efficient on filesystems that support them. (for example XFS, Btrfs, Bcachefs, ZFS, CIFS, NFS, OCFS2, overlayfs, APFS, ReFS. Notable exceptions include Ext4 and NTFS)
GNU Coreutils’s cp
use reflinks opportunistically (--reflink=auto
) by default as of version 9.0 (2021)
I suggest we bring reflink to shutil.copy2, something like
shutil.copy2(src, dst) # opportunistically use reflink (default)
shutil.copy2(src, dst, reflink=None) # same as above
shutil.copy2(src, dst, reflink=False)# never use reflink
shutil.copy2(src, dst, reflink=True) # raise OSError if reflink fails