From 9cb117b24b3d4b6baca539446fe8c3cc37ec4a1b Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Sun, 21 May 2023 11:06:29 +0200 Subject: [PATCH] Avoid explicit loop when updating OrderedSet --- xarray/core/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xarray/core/utils.py b/xarray/core/utils.py index 6ed0b2c4318..7270a8f587f 100644 --- a/xarray/core/utils.py +++ b/xarray/core/utils.py @@ -536,8 +536,7 @@ def discard(self, value: T) -> None: # Additional methods def update(self, values: Iterable[T]) -> None: - for v in values: - self._d[v] = None + self._d.update(dict.fromkeys(values)) def __repr__(self) -> str: return f"{type(self).__name__}({list(self)!r})"