The following table gives the time complexity of a dictionary using Big O notation:
Dictionary | Time complexity |
Get a value or a key | O(1) |
Set a value or a key | O(1) |
Copy a dictionary | O(n) |
An important thing to note from the complexity analysis of the dictionary is that the time taken to get or set a key-value is totally independent of the size of the dictionary. This means that the time taken to add a key-value pair to a dictionary of a size of three is the same as the time taken to add a key-value pair to a dictionary of a size of one million.