dict(A.keys(B)) returns a list of all keys of a dictionary. The order of the keys is implementation specific but deterministic and reflects the order of the values in values().