[issue23161] collections.abc.MutableSet missing methods

2015-01-04 Thread Martin Panter

Martin Panter added the comment:

For what it’s worth, every now and then I have to stop and remember that I 
can’t do this sort of thing:

unsupported_keys = config_dict.keys().difference(supported_list)

though it is not a big problem to rewrite it as

unsupported_keys = config_dict.keys() - set(supported_list)

Also it looks like one can already effectively do x.copy() using the existing 
immutable Set operators, so that worm can is already opened:

>>> ListBasedSet("abc") & ListBasedSet("abc")
<__main__.ListBasedSet object at 0x7f419951b860>

On the other hand, a matching almost equivalent operator does exist for 
a.issubset(b): a <= b, or a.__le__(b).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23161] collections.abc.MutableSet missing methods

2015-01-04 Thread Devin Jeanpierre

Devin Jeanpierre added the comment:

copy() should not be implemented magically, no.

I understand the argument in favor of not implementing redundant methods, but 
if the redundancy was this big a concern, they should not have been added to 
sets in the first place. The current ABCs are inconsistent and confusing. For 
example: MutableSequence implements += and .extend, but on MutableSet, the 
analogous methods |= and .update are only half there. (Moreover, it's the wrong 
half, in my experience.) Plus not all of the named methods have operator 
equivalents, so e.g. is_subset is not supported, but is_disjoint is.

This also means every subclass, in order to actually implement the set API, 
needs to write this code itself. It is very common to call the named methods, 
especially ones like update, and compatibility with set is desirable -- 
otherwise, we wouldn't bother inheriting from the relevant ABC.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23161] collections.abc.MutableSet missing methods

2015-01-04 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The r-methods have already been implemented.  Here's the difference as of 
Python 3.4.2:

>>> set(dir(set)) - set(dir(collections.abc.MutableSet))
{'update', 'difference_update', 'symmetric_difference', 'intersection_update', 
'intersection', 'issubset', 'issuperset', 'difference', 'copy', 
'symmetric_difference_update', 'union'}

Guido intentionally omitted the named set-to-set operations in favor of the 
operator versions (__ior__, __lt__, etc).  It was not the intention of the ABC 
to implement the full API (see Guido's PEP 3119 for more of his rationale.

The copy() method was also omitted on purpose. It is a bit of a can-of-worms 
for abstract class to know everything it needs to copy the the concrete set.  
This work is best left to the subclass which has the required knowledge.

I'm closing this one because I'm channeling Guido and thinking he really didn't 
want those methods as part of the ABC.

--
nosy: +rhettinger
resolution:  -> rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23161] collections.abc.MutableSet missing methods

2015-01-04 Thread Martin Panter

Changes by Martin Panter :


--
nosy: +vadmium

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23161] collections.abc.MutableSet missing methods

2015-01-03 Thread Devin Jeanpierre

Changes by Devin Jeanpierre :


--
components: +Library (Lib)

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23161] collections.abc.MutableSet missing methods

2015-01-03 Thread Devin Jeanpierre

New submission from Devin Jeanpierre:

>>> set(dir(set)) - set(dir(collections.abc.MutableSet))
{'copy', 'update', '__rsub__', 'union', 'issubset', 'intersection', 
'issuperset', '__rxor__', 'difference', 'symmetric_difference', 
'difference_update', '__rand__', 'intersection_update', 
'symmetric_difference_update', '__ror__'}

Most of these should be implemented on MutableSet rather than subclasses.

--
messages: 233398
nosy: Devin Jeanpierre
priority: normal
severity: normal
status: open
title: collections.abc.MutableSet missing methods
versions: Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com