On 29-Jan-08, at 2:29 PM, Greg Ewing wrote:

> Jim Jewett wrote:
>
>> The majority of uses need a mutable set that starts empty.
>
> Does anyone have evidence to support that assertion?
>
> Thinking about my own code, I probably do membership
> tests on constant sets (represented as tuples) about as
> often as I build up mutable sets (or some equivalent data
> structure).

over 120k loc:

All uses of set():

$ pygrep '[^.a-z]set[(]' | grep -v unittest | wc
     320    1583   24774

Empty set():

$ pygrep '[^.a-z]set[(][)]' | grep -v unittest | wc
     114     478    7406

Some of the uses in the first group could be replaced with frozenset,  
of course.  Looking at the examples, though, I would say that most of  
the uses of sets start out using a set constructed using  
comprehension or set(<iterable>).

I think that 'set()' is a perfectly fine and readable empty set  
"literal".

-Mike
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to