Paul Rubin wrote: > Peter Otten <__peter__ at web.de> writes: >> assert len(keydict) == len(mydict) > > assert set(keydict) == set(mydict) The weaker check is O(1), and, combined with the succeeding for loop, implies the above.