(original) (raw)
changeset: 88268:536a2cf5f1d2 user: Daniel Holth dholth@fastmail.fm date: Thu Jan 02 23:17:21 2014 -0500 files: Lib/zipfile.py description: Issue #18585: speed zipfile import by only generating zipfile._ZipDecryptor on demand diff -r dee33603a5fa -r 536a2cf5f1d2 Lib/zipfile.py --- a/Lib/zipfile.py Fri Jan 03 03:26:47 2014 +0100 +++ b/Lib/zipfile.py Thu Jan 02 23:17:21 2014 -0500 @@ -475,13 +475,15 @@ 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 /dholth@fastmail.fm