Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python ZipFile module extracts password protected zips slowly

i am trying to write a python-script, which should extract a zip file:

Board: Beagle-Bone black ~ 1GHz Arm-Cortex-a8, debian wheezy Zipfile: /home/milo/my.zip, ~ 8 MB

>>> from zipfile import ZipFile
>>> zip = ZipFile("/home/milo/my.zip")
>>> zip.extractall(pwd="tst")

other solutions with opening and reading-> writing the zipfile and extracting even particular file have the same effect. extracting take about 3-4 minutes.

Extracting the same file with just using unzip-tool takes less than 2 seconds.

Does anyone know what is wonrg with my code, or even with python zipfile lib??

Thanks Ajava

like image 670
arash javanmard Avatar asked Sep 01 '14 07:09

arash javanmard


1 Answers

This seems to be a documented issue with the ZipFile module in Python 2.7. If you look at the documentation for ZipFile, it clearly mentions:

Decryption is extremely slow as it is implemented in native Python rather than C.

If you need faster performance, you can either invoke an an external program (like unzip or 7zip) from your code, or make sure the zip files you are working with are not password protected.

like image 83
Tanuj Mathur Avatar answered Sep 24 '22 03:09

Tanuj Mathur