This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Let set.union and set.intersection accept multiple arguments
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 3.0
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: arno, rhettinger
Priority: normal Keywords: patch

Created on 2008-06-09 23:01 by arno, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
set_ui_varargs.diff arno, 2008-06-09 23:01 patch to Objects/setobject.c and Lib/test/
Messages (3)
msg67878 - (view) Author: Arnaud Delobelle (arno) Date: 2008-06-09 23:01
The patch allows the following syntax for s set/frozenset:
* s.union(a, b, c,...)
* s.update(a, b, c,...)
* s.intersection(a, b, c,...)
* s.intersection_update(a, b, c,...)

By extension:
* set.union(a, b, c,...) # provided a is a set/frozenset
* ...

Union is extended by iterative application of set_union_internal
Intersection is optimized by sorting all sets/frozensets/dicts in 
increasing order of size and only iterating over elements in the 

This was discussed on python-ideas:
msg67879 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-06-09 23:15
Time machine -- I already put in a version of this last night.  See 
r64051 and r64055.

Will take a look at your code to see if I can incorporate the sorting 
for insection() and harvest it for more tests.
msg67881 - (view) Author: Arnaud Delobelle (arno) Date: 2008-06-09 23:41
I must have diffed my patch against the wrong revision then, because I 
haven't seen it.  I had finished it last thursday, but have had a very 
hectic few days and only found a few minutes to send it this evening.  
Something must have gone wrong & the patch must be against last thursday's 
revision I guess.

Anyway it doesn't matter too much as you have started making the changes 
and it's easy to isolate set_intersection, which is a whole new function, 
in the patch file.
Date User Action Args
2022-04-11 14:56:35adminsetgithub: 47319
2008-06-22 22:22:10rhettingersetstatus: open -> closed
2008-06-09 23:41:25arnosetmessages: + msg67881
2008-06-09 23:15:38rhettingersetassignee: rhettinger
messages: + msg67879
nosy: + rhettinger
2008-06-09 23:01:51arnocreate