In previous answers, it is recommended to use the python tarfile module to create a .tar.gz file in python. This is obviously a good Python-style solution, although it does have a serious flaw in archiving speed. This question mentions that tarfile about twice as slow as calling a direct command on Linux. In my experience, this estimate is pretty true.
Therefore, for faster archiving, you can use the direct Linux command using the subprocess module:
subprocess.call(['tar', '-czf', output_filename, file_to_archive])
Aleksandr Tukallo Jul 19 '19 at 11:55 am 2019-07-19 11:55
source share