From 30a9bfde9a5628b51daf6de4d220adf1a558b157 Mon Sep 17 00:00:00 2001 From: Shamir Alavi Date: Thu, 7 Dec 2023 01:30:19 -0500 Subject: [PATCH] Update time complexity in update.rst The time complexity of dictionary update is linear, i.e. O(N). The C implementation of Python dictionary does resizing, hasing and deleting in an amortized O(1) time. So, the update method, which uses the C implementation of the dict_merge() function as source, uses a for loop to update the dictionary. Sources: https://hg.python.org/cpython/file/tip/Objects/dictobject.c https://archive.org/details/pyvideo_276___the-mighty-dictionary-55 https://stackoverflow.com/questions/20906435/does-dictionary-do-resize-when-we-delete-an-item https://stackoverflow.com/questions/52504598/time-complexity-of-python-dictionary-get-update-always-o1 --- source/docs/dict/update.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/docs/dict/update.rst b/source/docs/dict/update.rst index a2ffe7d..798cd1f 100644 --- a/source/docs/dict/update.rst +++ b/source/docs/dict/update.rst @@ -19,7 +19,7 @@ Return Value Time Complexity =============== -#TODO +$O(N)$ - linear time Example 1 =========