Here I'm using the code in python like:
if option2 == 1:
try:
global option2, Nimages
for sur in fm_path:
shutil.copy(sur,file1) # here how to speed up the copy function
option2 = 0
except shutil.Error as e:
print('Error: %s' % e)
While executing this, if I copy a lengthy file it took too much time to copy. Any suggestion to reduce the time?
If you are dealing with files with big size, you could try to do file open/write as a copy. As mentioned in Faster Python File Copy, the default buffer size in
shutil.copyfileobj
(which is the real function doing file-copy inshutil
) is 16*1024, 16384. You can use bigger buffer size then.ex,