[Python-ideas] universal set object for use in set manipulation

Raymond Hettinger python at rcn.com
Fri Jul 24 00:40:02 CEST 2009


[Andy Kish]
>    set_intersection = set.universal()
>    for s in sets:
>        set_intersection &= s

-1 This complicates the API and the implementation for very little benefit (saving you from writing a tiny, clear helper function for an uncommon use case).

Currently, sets enjoy a near zero learning curve.  That would be lost by adding set.universal() whose semantics are not immediately obvious -- for example, with s=set.universal() what is the meaning of list(s) or frozenset(s) or s.pop(); what is its repr value; and what is s^set('abc') or s-set('abc') or other operations?  You may be able to come-up with definitions that work, but those won't be intuitive to most users.


Raymond



More information about the Python-ideas mailing list