Skip to content

Commit d35504d

Browse files
committed
Merge branch 'main' into feature/uniform
2 parents 4b8d4e2 + e9f70d2 commit d35504d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

CHANGES.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
v4.3.0
1+
v4.4.0
22
=======
33

44
* Remove SelectableGroups deprecation exception for flake8.
55

6+
v4.3.0
7+
=======
8+
9+
* #317: De-duplication of distributions no longer requires
10+
loading the full metadata for ``PathDistribution`` objects,
11+
entry point loading performance by ~10x.
12+
613
v4.2.0
714
=======
815

importlib_metadata/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,11 @@ def name(self):
490490
"""Return the 'Name' metadata for the distribution package."""
491491
return self.metadata['Name']
492492

493+
@property
494+
def _normalized_name(self):
495+
"""Return a normalized version of the name."""
496+
return Prepared.normalize(self.name)
497+
493498
@property
494499
def version(self):
495500
"""Return the 'Version' metadata for the distribution package."""
@@ -797,6 +802,12 @@ def read_text(self, filename):
797802
def locate_file(self, path):
798803
return self._path.parent / path
799804

805+
@property
806+
def _normalized_name(self):
807+
stem = os.path.basename(str(self._path))
808+
name, sep, rest = stem.partition('-')
809+
return name
810+
800811

801812
def distribution(distribution_name):
802813
"""Get the ``Distribution`` instance for the named package.
@@ -851,7 +862,8 @@ def entry_points(**params) -> Union[EntryPoints, SelectableGroups]:
851862
852863
:return: EntryPoints or SelectableGroups for all installed packages.
853864
"""
854-
unique = functools.partial(unique_everseen, key=operator.attrgetter('name'))
865+
norm_name = operator.attrgetter('_normalized_name')
866+
unique = functools.partial(unique_everseen, key=norm_name)
855867
eps = itertools.chain.from_iterable(
856868
dist.entry_points for dist in unique(distributions())
857869
)

0 commit comments

Comments
 (0)