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

Terry Jones terry at jon.es
Fri Jul 24 12:07:20 CEST 2009


>>>>> "Terry" == Terry Reedy <tjreedy at udel.edu> writes:
Terry> Terry Jones wrote:
>> See also this thread:
>> 
>> http://mail.python.org/pipermail/python-dev/2006-May/064977.html
>> 
>> I implemented some of what I was proposing there (in Python though, not C),
>> and am happy to send people the code if there's any interest.
[snip]
Terry> Did you register a module with PyPI?

No.

Terry> In any case, it seems to me that adding a 'universal set' to the set
Terry> class does not work.  On the otherhand, a separate set-complement
Terry> class (which I am guessing is what you did) should work fine as far
Terry> as it goes. Each instance would have normal set as its data member,
Terry> and operations on complements and mixed operations would be defined
Terry> in terms of operations on sets. A universal set would then be an
Terry> instance with an empty set for a complement.

Yes, that's all exactly what I did.  I'll clean it up a little and post it
somewhere, PyPI I guess.

BTW, in my original posting I was wondering about this being added to
Python as a generalization of the set type. After the discussion in the
above thread and thinking through the various oddities it would introduce,
I also concluded that would be a mistake - there's just too much that's a
bit weird.  Raymond is right that a strong virtue of the current set module
is its simplicity. It's not worth blowing that so as to add a more general
behavior that very few people will ever use.  But it would be a nice 3rd
party module.

Terry



More information about the Python-ideas mailing list