Tarfile: compressor options

In tar we could set environment variables like XZ_DEFAULTS or (for GNU tar, not sure about others) use the -I option to customize the behavior of the compressor. Among other things, it allows for

  • defining a better speed/size tradeoff by playing with the levels
  • for LZMA, a lot of filter chain magic: BCJ on executable files, delta on simple waveform data, and tweaking of LZMA pb for known alignment. The theory for what these arguments do is in xz - manned.org.

Maybe we should have a way to do the same thing? Say, we take a new dict argument called cmp_options in tarfile.open(), and just splat it into kwargs when we create the compressor object, like self.cmp = lzma.LZMACompressor(**self.cmp_options).

Of course there’s the option to do the compressor-feeding manually, in a separate step or via some chaining of file objects. But tarfile already handles talking to compressors and a little shunt for options is a simple change.