Python: how to create tar file and compress it on the fly with external module, using different compression methods not available in tarfile module? -
i'm trying set code pack few big files (from tens hundreds of gigabytes) 1 archive. compression methods supported in tarfile module bit slow such big amount of data, use external compress module lz4 achive better speed of compression. unfortunately can't find way how create tar file , compress lz4 on fly avoid creating temporary tar file. documentation of tarfile module says there's way open uncompressed stream writing using 'w|' mode. way stream tar file directly lz4 module? if so, what's proper way use it? thank much.
per our conversation above.
import tarfile import subprocess p = subprocess.popen(['lz4', '-'], stdin=subprocess.pipe) tar = tarfile.open(fileobj=p.stdin, mode="w|")
from there can usual tar.addfile
. fyi: stated in conversation. gnu tar can auto detect gz , bz2 not lz4. note. have lz4 -c -d stdin.lz4 | tar xf -
extract files. if did tar xf
fail.
Comments
Post a Comment