[issue22089] collections.MutableSet does not provide update method
Akira Li
report at bugs.python.org
Tue Jul 29 23:06:27 CEST 2014
Akira Li added the comment:
On the other hand update() method may accept multiple iterables at once:
def update(self, *iterables):
for it in iterables:
self |= it
and therefore it is not equivalent to __ior__ method. In this case:
'difference', 'intersection', 'union' set methods could also be added to
Set and 'difference_update', 'intersection_update', 'update' to
MutableSet.
Negative consequences:
- no use-case?
- there are more than one way to spell an operation e.g., &= and
intersection_update for a single iterable case
- documentation, tests, methods implementation have to be maintained in
sync with frozenset/set
Positive:
- Set/MutableSet can be a drop in replacement for frozenset/set without
manually reimplementing the named methods even if multiple iterables
are not used
- documentation, tests, methods implementation are maintained only in
stdlib and therefore bugs are fixed in a single place and the same
behavior everywhere
I've uploaded a prototype patch that implements the named methods,
mentions them in Set/MutableSet documentation, and adds sanity tests.
If somebody provides a compelling use-case for adding the named methods
then further work on the patch could be done.
----------
keywords: +patch
Added file: http://bugs.python.org/file36152/set-update.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22089>
_______________________________________
More information about the Python-bugs-list
mailing list