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


S

Stef Mientki

hello,

I want to make a distro for Ubuntu,
and run under Windows.

I packed all sources with zipfile,
but the compression doesn't seem to be very good.

If run the created file through 7zip, it becomes anout half the size.

Is there a way to accomplish the same task with zipfile ( the
documentation isn't overwhelming).

thanks,
Stef Mientki
 
Ad

Advertisements

P

Peter Otten

Stef said:
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...

Peter
 
S

Stef Mientki

Peter said:
Stef Mientki wrote:



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) ?

thanks,
Stef Mientki
 
C

Chris Rebert

.. and would you be willing to tell me how I could set the compression ( at
maximum) ?

If you had glanced @ the docs for 30 seconds:

import zipfile
z = zipfile.ZipFile(dest_file, "w", zipfile.ZIP_DEFLATED)

Cheers,
Chris
 
P

Peter Otten

Stef said:
.. 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)

Peter
 
S

Stef Mientki

Peter said:
Stef Mientki wrote:



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,
I did a few tests, and I made a mistake with these experiments.
Indeed the compression is much better now, just 15% larger than 7zip,
which is quit acceptable.

thanks again,
Stef
 
Ad

Advertisements

C

Chris Rebert

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
 
Ad

Advertisements

R

R. David Murray

Chris Rebert said:
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.

Georg's been fixing the method signatures bit by bit to use keyword style.
Doc patches would be welcome to help speed up the conversion process.

--David
 

Top