News for hackers. Stuff that matters.
Re:PEP 584 – Add + and – operators to the built-in dict class by kbd on Wednesday March 06, 2019 @05:03AM (#19317710)
If dicts did subclass sets, then sets would be dicts whose values are all None. In other words, your last example would be defined as:

    >>> s = {'one', 'two'}
    >>> d = {}
    >>> d.update(s)
    >>> d
    {'two': None, 'one': None}
Re:PEP 584 – Add + and – operators to the built-in dict class by pdpi on Wednesday March 06, 2019 @06:41AM (#19318144)
If sets are dicts with values of None, then they're dicts, not a superclass of dict.
Re:PEP 584 – Add + and – operators to the built-in dict class by eesmith on Wednesday March 06, 2019 @06:28PM (#19324057)
Would s["one"] = 1 raise an exception? Or convert the set into a dict? Or change the sentinel value for all the set elements?

None seem like a good design since it means either the instance change its class on the fly (which Python does support) or that a dict does not act like its parent set object, breaking the is-a relationship most people expect from an OO design.

It seems like the circle/ellipse problem, and the current implementation is the "drop all inheritance relationships" solution to that problem. https://en.wikipedia.org/wiki/Circle-ellipse_problem#Drop_al...

Re:PEP 584 – Add + and – operators to the built-in dict class by kbd on Wednesday March 06, 2019 @07:50PM (#19324619)
> Would s["one"] = 1 raise an exception?

Sets don't support indexing, so it would still raise an exception. Dicts do, which is an example of them supporting more operations than sets, which is an example of why (if there is to be any subclass relation) dicts are subclasses of sets.

Edit: I suppose there's some confusion about my language above. "then sets would be dicts whose values are all None" could more helpfully read "sets would be equivalent to dicts whose...".