Skip to content

Commit 0a9b71a

Browse files
authored
Use a frozenset for _stdlib_list_with_cache()
1 parent 7c46682 commit 0a9b71a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

stdlib_list/base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,17 @@ def stdlib_list(version: str | None = None) -> list[str]:
5858

5959
data = pkgutil.get_data("stdlib_list", module_list_file).decode() # type: ignore[union-attr]
6060

61-
result = [y for y in [x.strip() for x in data.splitlines()] if y]
61+
result = [y for x in data.splitlines() if (y := x.strip())]
6262

6363
return result
6464

6565

6666
@lru_cache(maxsize=16)
67-
def _stdlib_list_with_cache(version: str | None = None) -> list[str]:
67+
def _stdlib_list_with_cache(version: str | None = None) -> frozenset[str]:
6868
"""Internal cached version of `stdlib_list`"""
69-
return stdlib_list(version=version)
69+
return frozenset(stdlib_list(version=version))
7070

7171

72-
@lru_cache(maxsize=256)
7372
def in_stdlib(module_name: str, version: str | None = None) -> bool:
7473
"""
7574
Return a ``bool`` indicating if module ``module_name`` is in the list of stdlib

0 commit comments

Comments
 (0)