diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py index 51263d696a1777..ad2f01b9653603 100644 --- a/Lib/_collections_abc.py +++ b/Lib/_collections_abc.py @@ -967,8 +967,8 @@ def update(self, other=(), /, **kwds): In either case, this is followed by: for k, v in F.items(): D[k] = v ''' if isinstance(other, Mapping): - for key in other: - self[key] = other[key] + for key, value in other.items(): + self[key] = value elif hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-06-16-18-16-41.gh-issue-135575._N5rTH.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-16-18-16-41.gh-issue-135575._N5rTH.rst new file mode 100644 index 00000000000000..5b5bef87bd4949 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-16-18-16-41.gh-issue-135575._N5rTH.rst @@ -0,0 +1 @@ +Improved performance of :meth:`collections.abc.MutableMapping.update`.