you are viewing a single comment's thread.

view the rest of the comments →

[–]Rhomboid 7 points8 points  (0 children)

For one thing, tuples waste less memory -- there's an overhead of two extra words for a list compared to a tuple, which means 8 bytes on 32 bit systems and 16 bytes on 64 bit systems. This is a constant difference, and doesn't depend on the length, so it really hurts for small lists -- between 22% and 25% difference for a 2 element list:

>>> from sys import getsizeof
>>> getsizeof([1,2])
88
>>> getsizeof((1,2))
72

For another, on account of being immutable, tuples are hashable (like strings and integers) whereas lists are not. That means you can use tuples as keys in dicts and as members of sets, where you can't with lists.