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

Mike Meyer mwm-keyword-python.b4bdba at mired.org
Fri Jul 24 01:04:54 CEST 2009


On Thu, 23 Jul 2009 18:29:14 -0400
George Sakkis <george.sakkis at gmail.com> wrote:
> Overall it seems like a non-solution to a non-problem.

It's definitely a real solution. The problem may not be very
important, though.

> Why don't we add a dict.universal(), list.universal(), etc. while
> we're at it.

Because a set of "all the things in the universe" makes sense as an
entity, whereas dict's or lists of "all the things in the universe"
don't. For lists, this implies some sort of ordering on everything in
the universe, which we've already abandoned as a bad idea. Dicts, on
the other hand, aren't simple collections, but maps, so you don't have
_a_ dict of everything in the universe, you have len(universe)**2 of
them. The def statement gives us the ability to express such maps.

Which may be how set.universal() stacks up: We can already create a
class that has the appropriate behaviors. It's not clear that that is
sufficiently useful to justify adding it to the language.

One thing that bugs me is the universal set is a *constant. It's value
doesn't change, so it shouldn't be a function or method, but an
attribute.

On the other hand, adding negative sets to the language provides an
easy way to express that constant, and certainly have more uses in
general. If we had to add one of the two, it'd be these. But I'm not
convinced that these have enough uses to justify adding them, either.

	  <mike
-- 
Mike Meyer <mwm at mired.org>		http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org



More information about the Python-ideas mailing list