List vs tuples
Roy Smith
roy at panix.com
Thu Apr 8 16:52:35 EDT 2004
In article <c54cjb$5fs$1 at planja.arnes.si>, "Mitja" <tezt at email.si>
wrote:
> A neewbie's question here, probably discussed before:
> what's the purpose of having both lists AND tuples?
> At the first (and second and third, to be honest) glance lists are just
> tuples with extended functionality, so why have tuples around?
> I've been working with Python for a few months now but haven't yet come
> across a problem that would really require tuples.
>
> Thanks in advance,
> Mitja
The biggest reason that I can think of is that tuples are immutable, and
you need an immutable object to be a dictionary key.
Also, without knowing the details of how they are implemented, my guess
would be that tuples are more efficient, as a direct result of their
immutability.
More information about the Python-list
mailing list