Py2.3: Feedback on Sets (fwd)

Gregor Lingl glingl at aon.at
Sat Aug 16 14:58:59 EDT 2003


David Mertz schrieb:

>>* Is there a compelling need for additional set methods like
>>   Set.powerset() and Set.isdisjoint(s) or are the current
>>   offerings sufficient?
> 
> 
> I confess that I have not used sets for anything beyond testing.  I love
> the concept, but I just haven't had the need yet (especially in
> something where I want to require 2.3).
> 
> The mention of Set.powerset() above is quite interesting to me.  It
> feels both exciting and dangerous :-).

I think it would be more general and versatile to provide a method for
the Cantorproduct of two sets, set1.cantorproduct(set2), which could be
used to define Set.powerset.
Additionally implementing this as __mul__ and __pow__ methods, so you
could write set1*set2 and set**n would be funny.

Regards, Gregor

> 
> As we all know, the size of the powerset of S, for len(S)==N, is 2**N.
> Seems like it would be really easy to run into some long runtimes and
> memory usage.  Then again, power set really is a fundamental operation
> on sets.  And making users rewrite it each time is error prone.
> 
> So I think I would advocate it, but with a fairly harsh warning in the
> documentation about complexity issues.
> 
> Yours, David...
> 
> --
> mertz@  | The specter of free information is haunting the `Net!  All the
> gnosis  | powers of IP- and crypto-tyranny have entered into an unholy
> .cx     | alliance...ideas have nothing to lose but their chains.  Unite
>         | against "intellectual property" and anti-privacy regimes!
> -------------------------------------------------------------------------
> X-Shameless-Plug:  Buy Text Processing in Python: http://tinyurl.com/jskh
> 
> 





More information about the Python-list mailing list