-
nested[1]
andnested[2]
have no effect whatsoever on the time taken to perform operations onnested[0]
. An object has no knowledge of what containers it might be referenced in or what other objects might be in the container with it. -
List operations take the same amount of time regardless of what objects are being added, removed, retrieved, or replaced. It doesn’t matter what
nested[2]
is;nested.pop(2)
takes the same amount of time. Hashing a large or highly nested tuple or other hashable object can take longer, so hash-based data structures likedict
andset
can take longer to work with large or highly nested keys, though there isn’t any such concern with the values.
solved How do nested variable types change time complexity?