I have a list of 20 file names, like [\'file1.txt\', \'file2.txt\', ...]. I want to write a Python script to concatenate these files into a new file. I could op
[\'file1.txt\', \'file2.txt\', ...]
outfile.write(infile.read()) # time: 2.1085190773010254s shutil.copyfileobj(fd, wfd, 1024*1024*10) # time: 0.60599684715271s
A simple benchmark shows that the shutil performs better.