Python 3.0 - is this true?

George Sakkis george.sakkis at
Mon Nov 10 17:05:40 CET 2008

On Nov 10, 4:10 am, "Martin v. Löwis" <mar... at> wrote:
> Roy Smith wrote:
> > Your
> > choice of containers is not based on any theoretical arguments of what each
> > type was intended to represent, but the cold hard reality of what
> > operations they support.
> Right. What seems missing is a "frozen list" type - the list needs to be
> frozen in order to be used as a dictionary key (or any other lookup
> structure). Fortunately, as you say, tuples already fill that role, so
> one could write
>   frozenlist = tuple
>   ...
>   sequence = frozenlist(items)
>   d[sequence] = d.get(sequence,0)+1
> to make it explicit that here, the tuple has a different role.

If list grew a frozenlist superclass (just move up all the non-
mutating methods of list) and had a new freeze method, there would be
no need to copy the sequence:

def freeze(self):
    self.__class__ = frozenlist


More information about the Python-list mailing list