|
10 | 10 | import os |
11 | 11 | import pathlib |
12 | 12 | import zipfile |
| 13 | +import collections |
| 14 | + |
13 | 15 | from abc import ABCMeta |
14 | 16 | from typing import Any, Dict, Generator, Iterable, List, Mapping, Optional, Tuple, Type |
15 | 17 |
|
@@ -410,19 +412,24 @@ def get_symbol(self, name: str) -> interfaces.symbols.SymbolInterface: |
410 | 412 | return self._symbol_cache[name] |
411 | 413 |
|
412 | 414 | @property |
413 | | - def symbols(self) -> Iterable[str]: |
414 | | - """Returns an iterator of the symbol names.""" |
415 | | - return list(self._json_object.get("symbols", {})) |
| 415 | + def symbols(self) -> collections.abc.KeysView[str]: |
| 416 | + """Returns a dictview of the symbol names.""" |
| 417 | + return self._json_object.get("symbols", {}).keys() |
416 | 418 |
|
417 | 419 | @property |
418 | | - def enumerations(self) -> Iterable[str]: |
419 | | - """Returns an iterator of the available enumerations.""" |
420 | | - return list(self._json_object.get("enums", {})) |
| 420 | + def enumerations(self) -> collections.abc.KeysView[str]: |
| 421 | + """Returns a dictview of the available enumerations.""" |
| 422 | + return self._json_object.get("enums", {}).keys() |
421 | 423 |
|
422 | 424 | @property |
423 | | - def types(self) -> Iterable[str]: |
424 | | - """Returns an iterator of the symbol type names.""" |
425 | | - return list(self._json_object.get("user_types", {})) + list(self.natives.types) |
| 425 | + def types(self) -> collections.abc.KeysView[str]: |
| 426 | + """Returns a dictview of the symbol type names.""" |
| 427 | + # self.natives.types is very small compared to user_types, so the dict overhead |
| 428 | + # can be neglected |
| 429 | + return { |
| 430 | + **self._json_object.get("user_types", {}), |
| 431 | + **dict.fromkeys(self.natives.types), |
| 432 | + }.keys() |
426 | 433 |
|
427 | 434 | def get_type_class(self, name: str) -> Type[interfaces.objects.ObjectInterface]: |
428 | 435 | return self._overrides.get(name, objects.AggregateType) |
|
0 commit comments