If you are asking how comparing dictionaries works, it is this:
To compare dicts A and B, first compare their lengths. If they are unequal, then return cmp(len(A), len(B). Next, find the key adiff in A that is the smallest key for which A[adiff] != B[adiff]. Also find the smallest key bdiff in B for which A[bdiff] != B[bdiff]. If adiff != bdiff, then return cmp(adiff, bdiff). Else return cmp(A[adiff], B[bdiff]).
In pseudo-code:
def smallest_diff_key(A, B):
"""return the smallest key adiff in A such that A[adiff] != B[bdiff]"""
diff_keys = [k for k in A if A.get(k) != B.get(k)]
return min(diff_keys)
def dict_cmp(A, B):
if len(A) != len(B):
return cmp(len(A), len(B))
adiff = smallest_diff_key(A, B)
bdiff = smallest_diff_key(B, A)
if adiff != bdiff:
return cmp(adiff, bdiff)
return cmp(A[adiff], b[bdiff])
This is translated from the 2.6.3 implementation in dictobject.c.