Is it safe to use frozenset as a dict key? Yes.
According to the docs, Frozenset is healable because it is immutable. This will mean that it can be used as a dictation key, since a hash is a prerequisite for the key.
From FrozenSet Documents
The frozenset type is immutable and hashed - its contents cannot be changed after it is created; therefore, it can be used as a dictionary key or as an element of another set.
And unnecessarily, from the dictionary of documents :
... keys that can be of any immutable type
For clarification, a set (by definition), frozen or not, does not preserve order. They are stored internally, taking into account an order that is not taken into account, and with the removal of duplicate elements, so two sets built in different orders will be equivalent keys in the dictionary - they are the same.
>>> frozenset([1,2,2,3,3]) == frozenset([3,2,1,1,1]) True
and also,
>>> d = {} >>> d[frozenset([1,1,2,3])] = 'hello' >>> d[frozenset([1,2,3,3])] 'hello' >>> d[frozenset([3,3,3,2,1,1,1])] 'hello' >>> d[frozenset([2,1,3])] 'hello'