[Tutor] Counting # of dictionary keys

Dana Larose dana@pixelenvy.ca
Wed Apr 16 09:56:02 2003

Hi everyone,

I'm curious about the following:

>>> len(your_dict)

What is the complexity of this operation?  Does it run in time O(1) or
O(n)?  If it doesn't, is there a O(1) method for determining the number of
key/value pairs in a dictionary?