PEP 218 Re: ANN: set-0.1 module available

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Mon May 20 14:06:00 EDT 2002


Steve Holden <sholden at holdenweb.com> wrote:
>I believe (without any worked-out justification) that Python could actually
>perform exactly the same comutations as it does now even if lists were
>removed: it would simply be more awkward and less efficient to compute with
>tuples, which are immutable.

a = [1, 2, 3]
b = a
b += [4, 5, 6]
print a

To achieve this with tuples you need to wrap them up in some other objects,
which is effectively another implementation of lists.

>If sets were to become a Python type I would expect that it would be useful
>to have both mutable and immutable variants, in just the same way as the
>sequences do. 

That is indeed the most sensible solution.  I'd even argue for two flavors
of dicts and two flavors of strings, too.

When two related things have different advantages over each other under
different circumstances, it is fruitless to argue which should be the ONE.
Better to have both.

It might even be easier to implement two flavors of everything if *every
kind* of object has a mutability flag.

Huaiyu



More information about the Python-list mailing list