add fixme about merge operator

This commit is contained in:
Abyss Watcher
2025-01-18 15:59:51 +01:00
parent 0ee016e655
commit c2ef3c2fe5
+6 -2
View File
@@ -422,8 +422,12 @@ class Version1Format(ISFormatTable):
@property
def types(self) -> Iterable[str]:
"""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
# We use ** instead of
# `set(self._json_object.get("user_types", {}).keys()).union(self.natives.types)`
# because converting user_types dict to a set is costly.
# It is more efficient to convert the (very small) self.natives.types set to a dict.
# FIXME: On Python3.8 support drop, merge the two dicts using the merge operator:
# (self._json_object.get("user_types", {}) | dict.fromkeys(self.natives.types)).keys()
return {
**self._json_object.get("user_types", {}),
**dict.fromkeys(self.natives.types),