Message224251
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. |
|
Date |
User |
Action |
Args |
2014-07-29 21:06:27 | akira | set | recipients:
+ akira, rhettinger, josh.r, roy.wellington |
2014-07-29 21:06:27 | akira | set | messageid: <1406667987.46.0.890865504326.issue22089@psf.upfronthosting.co.za> |
2014-07-29 21:06:27 | akira | link | issue22089 messages |
2014-07-29 21:06:27 | akira | create | |
|