[Python-3000] sets in P3K?

Antoine Pitrou solipsis at pitrou.net
Wed May 3 15:37:14 CEST 2006


Le mercredi 03 mai 2006 à 09:22 -0400, Greg Wilson a écrit :
> I obviously haven't done the experiment yet, but I can pretty much
> guarantee you that newbies will trip over the inconsistency you're
> proposing:
> 
>     Type    Two elements        One element        Empty
>     List    [1, 2]              [1]                []
>     Dict    {1:'a', 2:'b'}      {1:'a'}            {}
>     Set     {1, 2}              {1}                set()
> 
> One of these things is not like the others...  One of these things just
> doesn't belong...  Or is "regular enough that newcomers' guesses about
> what to type are usually right" no longer a design consideration?

Something has to be sacrificed anyway, because there is no way to have a
simple and obvious notation for all three types (I do not find {:} or
{/} simple and obvious).

I think lists and dicts are fundamental data types for which there is an
immediate need, whereas sets are an useful optimization, like dequeues
or heaps. Therefore sets are less likely to be used by newcomers.

One symptom of that is that lists and dicts also have syntactic support
in e.g. PHP or Perl, whereas sets don't.




More information about the Python-3000 mailing list