zipfile doesn't compress very good, are there other solutions?

Chris Rebert clp2 at rebertia.com
Thu Jun 11 16:58:43 EDT 2009


On Thu, Jun 11, 2009 at 1:41 PM, Stef Mientki<stef.mientki at gmail.com> wrote:
> Peter Otten wrote:
>> Stef Mientki wrote:
>>> Peter Otten wrote:
>>>> Stef Mientki wrote:
>>>>> I packed all sources with zipfile,
>>>>> but the compression doesn't seem to be very good.
>>>>>
>>>>
>>>> If you don't specify the compression, the files are not compressed at
>>>> all. Just in case you didn't know...
>>>>
>>>
>>> .. and would you be willing to tell me how I could set the compression (
>>> at maximum) ?
>>>
>>
>> According to the documentation (hint, hint) there is only on and off.
>>
>> zipfile.ZipFile(filename, "w", compression=zipfile.ZIP_DEFLATED)
>>
>>
>
> sorry guys I made a mistake,
> I did read the doc, but as there was no default value metioned,

Erm...

class zipfile.ZipFile(file[, mode[, compression[, allowZip64]]])

    Open a ZIP file [...] compression is the ZIP compression method to
use when writing the archive, and should be ZIP_STORED or
ZIP_DEFLATED; [...] The default is ZIP_STORED. [...]

Though I admit the docs could definitely do with having
"compression=ZIP_STORED" in the signature part of the doc.

Cheers,
Chris
-- 
http://blog.rebertia.com



More information about the Python-list mailing list