Skip to content

Commit 78a0381

Browse files
committed
Merge branch 'master' into bugfix/94-bad-path
2 parents ca145b5 + e4f1258 commit 78a0381

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

.gitlab-ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ coverage:
2222
paths:
2323
- coverage.xml
2424

25+
benchmark:
26+
script:
27+
- tox -e perf
28+
2529
diffcov:
2630
script:
2731
- tox -e py27-diffcov,py35-diffcov,py36-diffcov,py37-diffcov,py38-diffcov

importlib_metadata/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ class FastPath:
408408

409409
def __init__(self, root):
410410
self.root = root
411+
self.base = os.path.basename(root).lower()
411412

412413
def joinpath(self, child):
413414
return pathlib.Path(self.root, child)
@@ -430,12 +431,11 @@ def zip_children(self):
430431
)
431432

432433
def is_egg(self, search):
433-
root_n_low = os.path.split(self.root)[1].lower()
434-
434+
base = self.base
435435
return (
436-
root_n_low == search.normalized + '.egg'
437-
or root_n_low.startswith(search.prefix)
438-
and root_n_low.endswith('.egg'))
436+
base == search.versionless_egg_name
437+
or base.startswith(search.prefix)
438+
and base.endswith('.egg'))
439439

440440
def search(self, name):
441441
for child in self.children():
@@ -456,6 +456,7 @@ class Prepared:
456456
prefix = ''
457457
suffixes = '.dist-info', '.egg-info'
458458
exact_matches = [''][:0]
459+
versionless_egg_name = ''
459460

460461
def __init__(self, name):
461462
self.name = name
@@ -465,6 +466,7 @@ def __init__(self, name):
465466
self.prefix = self.normalized + '-'
466467
self.exact_matches = [
467468
self.normalized + suffix for suffix in self.suffixes]
469+
self.versionless_egg_name = self.normalized + '.egg'
468470

469471

470472
@install

importlib_metadata/docs/changelog.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@
22
importlib_metadata NEWS
33
=========================
44

5+
v1.5.0
6+
======
7+
8+
* Additional performance optimizations in FastPath now
9+
saves an additional 20% on a typical call.
10+
511
v1.4.0
612
======
713

814
* Through careful optimization, ``distribution()`` is
915
3-4x faster. Thanks to Antony Lee for the
1016
contribution. Closes #95.
1117

18+
* When searching through ``sys.path``, if any error
19+
occurs attempting to list a path entry, that entry
20+
is skipped, making the system much more lenient
21+
to errors. Closes #94.
22+
1223
v1.3.0
1324
======
1425

tox.ini

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = {py27,py35,py36,py37,py38}{,-cov,-diffcov},qa,docs
2+
envlist = {py27,py35,py36,py37,py38}{,-cov,-diffcov},qa,docs,perf
33
skip_missing_interpreters = True
44

55

@@ -61,6 +61,14 @@ extras =
6161
docs
6262

6363

64+
[testenv:perf]
65+
use_develop = False
66+
deps =
67+
ipython
68+
commands =
69+
python -m timeit -s 'import importlib_metadata' -- 'importlib_metadata.distribution("ipython")'
70+
71+
6472
[testenv:release]
6573
basepython = python3
6674
deps =

0 commit comments

Comments
 (0)