summaryrefslogtreecommitdiff
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorDaniel Holth <dholth@fastmail.fm>2014-01-02 23:17:21 -0500
committerDaniel Holth <dholth@fastmail.fm>2014-01-02 23:17:21 -0500
commit9dee304205d34a8565f922fdad5b0f89fcff65a5 (patch)
treee5737ccb565dc3ba69260bb9da3c3c80ae94870c /Lib/zipfile.py
parentdaeffd2c08f8a04818b99e8342da79cf98ab730a (diff)
downloadcpython-git-9dee304205d34a8565f922fdad5b0f89fcff65a5.tar.gz
Issue #18585: speed zipfile import by only generating zipfile._ZipDecryptor on demand
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r--Lib/zipfile.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index fad52a246d..173d99080c 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -475,13 +475,15 @@ class _ZipDecrypter:
crc = ((crc >> 1) & 0x7FFFFFFF)
table[i] = crc
return table
- crctable = _GenerateCRCTable()
+ crctable = None
def _crc32(self, ch, crc):
"""Compute the CRC32 primitive on one byte."""
return ((crc >> 8) & 0xffffff) ^ self.crctable[(crc ^ ch) & 0xff]
def __init__(self, pwd):
+ if _ZipDecrypter.crctable is None:
+ _ZipDecrypter.crctable = _ZipDecrypter._GenerateCRCTable()
self.key0 = 305419896
self.key1 = 591751049
self.key2 = 878082192