Lists vs tuples (newbie)
rzed
rzantow at gmail.com
Mon May 21 08:01:24 EDT 2007
Szabolcs <szhorvat at gmail.com> wrote in
news:f2s0ut$128f$1 at toralf.uib.no:
>
> I was wondering about why are there both tuples and lists? Is
> there anything I can do with a tuple that I cannot do with a
> list?
>
> In what circumstances is it advantageous to use tuples instead
> of lists? Is there a difference in performance?
>
> I am still learning Python, so please be gentle ...
>
This topic comes up from time to time in this newsgroup. If you want
a lot of viewpoints about it, Google is your friend.
A short answer, though: tuples can be used as dictionary keys and
lists cannot. I would guess (but would have to test to confirm) that
tuples occupy less space for the same data. I don't know whether any
differences in, say, iteration speed would be terribly significant,
but I would expect tuples to be marginally faster.
--
rzed
More information about the Python-list
mailing list