8000 Prefer a cached property, as the property is likely to be retrieved a… · python/importlib_metadata@9f8af01 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f8af01

Browse files
committed
Prefer a cached property, as the property is likely to be retrieved at least 3 times (on construction and for module:attr access).
1 parent f179e28 commit 9f8af01

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

importlib_metadata/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def attr(self) -> str:
233233
def extras(self) -> list[str]:
234234
return re.findall(r'\w+', self._match.extras or '')
235235

236-
@property
236+
@functools.cached_property
237237
def _match(self) -> _EntryPointMatch:
238238
match = self.pattern.match(self.value)
239239
if not match:

0 commit comments

Comments
 (0)
0