related to: pep-0584, PEP-0218, and ???
The request is that since dictionary keys can not be duplicated / are unique that they may behave the same as sets - and have the set operators actions and return sets.
eg.:
aSet = set('a','b','c','bar')
aDict = {'a':'aaa', 'b':'baa' , 'foo':fou' }
bDict = {'a':'ea', 'b':'bee' , 'foo':fuh', 'bar': 'drink' }
aSet | aDict | bDict
= set('a','b','c','foo','bar')
bDict & aDict
=set('a','b','foo')
bDict - aSet
=set('foo')
aDict^bDict
=set('bar')
The dictionary class would support set filtering:
New_dict_from_set = { your_key: old_dict[your_key] for your_key in aSET }
e.g. a function such as: (taking the intersection)
aDict.Subdictionary(aSet)
={'a':'aaa', 'b':'baa'}
set(dictionary) would return the Keys (as a mutable).
Adding an element to the mutable set would add a None as a value to the dictionary.
The "-=", "-", "+", "+=" would behave as specified in pep-0584 if both are dictionaries, but if one of the operands is a set - a set is returned.
The behaviour of
bDict.Subdictionary(aDict)
= {'a':'ea', 'b':'bee' , 'foo':fuh')
i.e. treats aDict as a set
aDict.Subdictionary(List)== aDict.Subdictionary(Set(List))