Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/spdl/io/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@


def __dir__() -> list[str]:
return sorted(__all__)
# Avoid sorting on every call by computing once.
# __all__ is static, so it's safe to cache.
# Cache the sorted list on the function object.
if not hasattr(__dir__, "_sorted_all"):
__dir__._sorted_all = sorted(__all__)
return __dir__._sorted_all


def __getattr__(name: str) -> ModuleType:
Expand Down