Python ZipFile module slowly retrieves password protected files

I am trying to write a python script that should extract a zip file:

Board: Beagle-bone black ~ 1GHz Arm-Cortex-a8 , Debian whistling 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 a zip file and extracting a specific file has the same effect. extraction takes about 3-4 minutes.

Retrieving the same file with only unzipping takes less than 2 seconds.

Does anyone know what my code will win, or even with python zipfile lib ??

Thanks Ajava

+5
source share
1 answer

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 states:

Decryption is very slow since it is implemented in native Python and not C.

If you need better performance, you can either call an external program (for example, unzip or 7zip) from your code, or make sure that the zip files you are working with are not password protected.

+4
source

Source: https://habr.com/ru/post/1201536/


All Articles