Py2.3: Feedback on Sets

Carl Banks imbosol at aerojockey.com
Tue Aug 12 05:09:42 EDT 2003


Raymond Hettinger wrote:
> I've gotten lots of feedback on the itertools module
> but have not heard a peep about the new sets module.
> 
> * Are you overjoyed/outraged by the choice of | and &
>   as set operators (instead of + and *)?

I slightly favor | and &.


> * Is the support for sets of sets necessary for your work
>   and, if so, then is the implementation sufficiently
>   powerful?
> 
> * Is there a compelling need for additional set methods like
>   Set.powerset() and Set.isdisjoint(s) or are the current
>   offerings sufficient?

I imagine isdisjoint would be useful, although it's easy enough to use
bool(s&t).


> * Does the performance meet your expectations?
> 
> * Do you care that sets can only contain hashable elements?
> 
> * How about the design constraint that the argument to most
>   set methods must be another Set (as opposed to any iterable)?
> 
> * Are the docs clear?  Can you suggest improvements?

Yeah: in the library reference, the table entry for s.union(t) should
say "synonym of s|t" instead of repeating the description.  This is
especially true because it's not clear from a simple glance whether
"s.union(t)" goes with "s|t" or "s&t", because it sits right between
the two.  Better yet, I would change it to a three-column table
(operation, synonym, result).


> * Are sets helpful in your daily work or does the need arise
>   only rarely?

I haven't used sets yet (or Python 2.3), but I expect to use them a
lot.  However, I imagine my typical use would be efficient testing for
membership.  I have maybe half a dozen places where I use a dictionary
for that now.



-- 
CARL BANKS
"You don't run Microsoft Windows.  Microsoft Windows runs you."




More information about the Python-list mailing list