Interesting question. The documentation of tarfile
(https://docs.python.org/3/library/tarfile.html) mentions that the
default format for tar archive created by tarfile
is, since python
3.8, PAX_FORMAT
whereas archives created by the tar
command have
the GNU format which I believe explains the difference.
Now to produce the same archive as the tar
command and one with the
default format (as your command did):
import tarfile
with tarfile.TarFile(name='archive-py-gnu.tar', mode='w', format=tarfile.GNU_FORMAT) as tf:
tf.add('tmp')
with tarfile.TarFile(name='archive-py-default.tar', mode='w') as tf:
tf.add('tmp')
For comparison:
$ tar cf archive-tar.tar tmp/
$ ls -l
3430400 16:28 archive-py-default.tar
3317760 16:28 archive-py-gnu.tar
3317760 16:27 archive-tar.tar
Results of the file
command:
$ file archive_unix.tar
archive_unix.tar: POSIX tar archive (GNU)
$ file archive-py-gnu.tar
archive-py-gnu.tar: POSIX tar archive (GNU)
$ file archive-py-default.tar
archive-py-default.tar: POSIX tar archive
Now I cannot tell you the difference between the different formats,
sorry. But I hope this helps.