tarfile...bug?

Scott David Daniels Scott.Daniels at Acm.Org
Sat Oct 13 17:26:51 EDT 2007


alan.haffner at gmail.com wrote:
> On Oct 9, 10:33 pm, Anurag <anuraguni... at gmail.com> wrote:
>> Have any one faced such problem, I assume it must be common if it can
>> be replicated so easily , or something wrong with my system
>>
>> Also if I use tar.members instead of tar.getmembers() it works
>> so what is the diff. between tar.members and tar.getmembers()
> 
> if you are not fully dependant on tarfiles, have a look at the zipfile
> library in Python.  Everytime I start to use the tarfile .lib, the
> zip .lib turns out to be a better solution.

And here's why:
The tar-gzip format (sometimes .tar.gz, sometimes .tgz) is defined by
taking a fully expanded archive (tar archives), and compressing them
_as_a_whole_ with the gzip compression.  It is not possible to see the
last bytes of the .tgz file without uncompressing _all_ of the file.

The  zip format compresses the contained files individually, and keeps
a separate directory.  So it can expand only the file you want whether
it is at the beginning or the end of the zip file.  This is also (one
of) the reason(s) the .zip format gets less compression than the .tgz
format.  Each file in the zip is separately compressed, so redundancy
between files is not compressed out.

-Scott David Daniels
Scott.Daniels at Acm.Org





More information about the Python-list mailing list