prefer KeysView iterable to lists

This commit is contained in:
Abyss Watcher
2025-01-18 14:51:31 +01:00
parent 1e9551b053
commit aa99410dd2
+13 -8
View File
@@ -411,18 +411,23 @@ class Version1Format(ISFormatTable):
@property
def symbols(self) -> Iterable[str]:
"""Returns an iterator of the symbol names."""
return list(self._json_object.get("symbols", {}))
"""Returns an iterable (KeysView) of the available symbol names."""
return self._json_object.get("symbols", {}).keys()
@property
def enumerations(self) -> Iterable[str]:
"""Returns an iterator of the available enumerations."""
return list(self._json_object.get("enums", {}))
def enumerations(self) -> Iterable[Any]:
"""Returns an iterable (KeysView) of the available enumerations."""
return self._json_object.get("enums", {}).keys()
@property
def types(self) -> Iterable[str]:
"""Returns an iterator of the symbol type names."""
return list(self._json_object.get("user_types", {})) + list(self.natives.types)
def types(self):
"""Returns an iterable (KeysView) of the available symbol type names."""
# self.natives.types (set) is generally very small compared to user_types,
# so the dict conversion overhead can be neglected
return {
**self._json_object.get("user_types", {}),
**dict.fromkeys(self.natives.types),
}.keys()
def get_type_class(self, name: str) -> Type[interfaces.objects.ObjectInterface]:
return self._overrides.get(name, objects.AggregateType)