Py2.3: Feedback on Sets (fwd)

Tim Peters tim.one at comcast.net
Mon Aug 18 06:10:08 CEST 2003


[Raymond Hettinger]
> ...
> The real issue with adding a module function or Set method for
> powerset is the lack of compelling use cases; without those, it is
> simply a cute example for the docs or an ASPN recipe.

I agree.

> Also, if Tim were to chime-in, I think he would abstract the
> problem and say that the algorithm falls in the domain of
> combinatorics (for which he has written a module) and that
> powersets are just a specific case of transforming a collection
> of items into a collection of all possible sub-collections.

Chiming.

It's more that the use cases for generating powersets demand several ways of
generating them:

+ Lexicographic (if the set elements are totally ordered).

+ Arbitrary Gray code (minimal change from one subset to the next).

+ App-specific Gray code (e.g., from one subset to the next,
  add or remove that specific element that makes the largest-- or
  smallest --change in the value of a function of the subset).

+ Any order at all (for apps that can't exploit a stronger
  guarantee, and want peak generation speed).

one-size-doesn't-fit-anybody-ly y'rs  - tim






More information about the Python-list mailing list