Using Python for file packing

Nobody nobody at nowhere.com
Tue Jun 30 07:30:42 EDT 2009


On Mon, 29 Jun 2009 14:16:34 -0700, Scott David Daniels wrote:

>>> Do you mean like a zip or tar file?
>>>
>>> http://docs.python.org/library/zipfile.htmlhttp://docs.python.org/library/tarfile.html
>>>
>> 
>> I had no idea you could access a single file from a ZIP or TAR without
>> explicitly extracting it somewhere. Thanks.
>
> You will find the zip format works better if you are compressing.  The
> zipfile compression is per file in the archive, rather than applied to
> the entire archive (as in tarfile).  The results of the tar format
> decision is that extracting the last file in a .tgz (.tar.gz) or
> .tar.bz2 (sometimes called .tbz) requires the expansion of the entire
> archive, while extraction on a .zip is reposition, read, and possibly
> expand.

Even without compression, the tar format is ill-suited to random access.
If you can choose the format, use a zip file.




More information about the Python-list mailing list