diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-02-12 03:21:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-12 03:21:32 (GMT) |
commit | ed4d263e8767b0e4c47df99141b500d36ce0275d (patch) | |
tree | 8abdb2a3ca1b863c451dbcca0be73b165dc605a1 /Lib/importlib/metadata.py | |
parent | 190433d8150bf719fa0ba972dbacf2214942f54e (diff) | |
download | cpython-ed4d263e8767b0e4c47df99141b500d36ce0275d.zip cpython-ed4d263e8767b0e4c47df99141b500d36ce0275d.tar.gz cpython-ed4d263e8767b0e4c47df99141b500d36ce0275d.tar.bz2 |
bpo-39595: Improve zipfile.Path performance (GH-18406) (GH-18472)
* Improve zipfile.Path performance on zipfiles with a large number of entries.
* 📜🤖 Added by blurb_it.
* Add bpo to blurb
* Sync with importlib_metadata 1.5 (6fe70ca)
* Update blurb.
* Remove compatibility code
* Add stubs module, omitted from earlier commit
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
(cherry picked from commit e5bd73632e77dc5ab0cab77e48e94ca5e354be8a)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Diffstat (limited to 'Lib/importlib/metadata.py')
-rw-r--r-- | Lib/importlib/metadata.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/importlib/metadata.py b/Lib/importlib/metadata.py index ae8ecf9..831f593 100644 --- a/Lib/importlib/metadata.py +++ b/Lib/importlib/metadata.py @@ -391,6 +391,7 @@ class FastPath: def __init__(self, root): self.root = root + self.base = os.path.basename(root).lower() def joinpath(self, child): return pathlib.Path(self.root, child) @@ -413,12 +414,11 @@ class FastPath: ) def is_egg(self, search): - root_n_low = os.path.split(self.root)[1].lower() - + base = self.base return ( - root_n_low == search.normalized + '.egg' - or root_n_low.startswith(search.prefix) - and root_n_low.endswith('.egg')) + base == search.versionless_egg_name + or base.startswith(search.prefix) + and base.endswith('.egg')) def search(self, name): for child in self.children(): @@ -439,6 +439,7 @@ class Prepared: prefix = '' suffixes = '.dist-info', '.egg-info' exact_matches = [''][:0] + versionless_egg_name = '' def __init__(self, name): self.name = name @@ -448,6 +449,7 @@ class Prepared: self.prefix = self.normalized + '-' self.exact_matches = [ self.normalized + suffix for suffix in self.suffixes] + self.versionless_egg_name = self.normalized + '.egg' class MetadataPathFinder(DistributionFinder): |