Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python ZipFile Slow for big files, Need Alternatives

I am using ZipFile in python to unzip a 6GB file. But it seems to be taking over 3hours to do so. I need to find a better alternative to fit within 20mins. Below is the code i have been working with which works perfectly fine but is very slow.

Python: 3.8.8

from zipfile import ZipFile
str_zipFile = 'C:\\Users\\Documents\\Test.zip'
str_pwd= '1234'

with ZipFile(str_zipFile) as zipObj:
    zipObj.extractall(pwd = bytes(str_pwd,'utf-8'))

Please suggest a faster method.

like image 536
KJoseph Avatar asked Aug 05 '26 07:08

KJoseph


1 Answers

Quote from Python zipfile module doc:

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

To get better performance, you can invoke an external program like unzip or 7z

like image 186
oeter Avatar answered Aug 07 '26 04:08

oeter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!