Currently the dictionary view objects behave exactly like sets when set 
operations defined on them are used, such as the pipe or ampersand operators:
>>> d.keys() | [1]
{1, 2}

dictionary views are even sets by the ABC standard, having support for all the 
required abstract methods:
>>> isinstance(d.keys(), collections.abc.Set)
True

However, the dict views do not have the equivalent named set methods, such as 
`intersection` or `issuperset`. It seems that the collections.abc.Set API was 
purposely crafted for returning True when a dict view is given as an argument 
to isinstance, as c urrently, the `isdisjoint` method is the only named method 
that the API requires.

I propose that the `Set` ABC API should be augmented to contain all of the 
named methods. This would provide consistency in the collections, and enhance 
the duck typing capabilities of the `Set` abc.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/YBIIMJP2HRQBGR2VENQ6XPYRDVHDXZVK/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to