Micro optimisation

This commit is contained in:
Kovid Goyal 2025-04-07 08:23:41 +05:30
parent b4251ab1be
commit d7d5144790
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1107,13 +1107,16 @@ class ZipFile:
'''
if members is None:
members = self.namelist()
if path is None:
path = os.getcwd()
# Kovid: Extract longer names first, just in case the zip file has
# an entry for a directory without a trailing slash
members.sort(key=len, reverse=True)
zimembers = tuple(map(self.getinfo, members))
for zipinfo in members:
self.extract(zipinfo, path, pwd)
for zipinfo in zimembers:
self._extract_member(zipinfo, path, pwd)
def _extract_member(self, member, targetpath, pwd):
'''Extract the ZipInfo object 'member' to a physical