Skip to content

Commit 913bae7

Browse files
authored
Use a frozenset for _stdlib_list_with_cache() (#167)
1 parent db9b6fe commit 913bae7

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
@@ -59,18 +59,17 @@ def stdlib_list(version: str | None = None) -> list[str]:
5959

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

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

6464
return result
6565

6666

6767
@lru_cache(maxsize=16)
68-
def _stdlib_list_with_cache(version: str | None = None) -> list[str]:
68+
def _stdlib_list_with_cache(version: str | None = None) -> frozenset[str]:
6969
"""Internal cached version of `stdlib_list`"""
70-
return stdlib_list(version=version)
70+
return frozenset(stdlib_list(version=version))
7171

7272

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

0 commit comments

Comments
 (0)