r/learnpython • u/Immediate_Pin_8449 • Oct 12 '26
Tuples..I don’t get it
Hi crew, I’m a Python newbie and I just learned about the concept of tuples.
We can’t change them.if we want to store we have to start at the index we want + 1.
I just don’t get it. Why wouldn’t we just use lists? When would we ever need this?
100
Upvotes
View all comments
Show parent comment
2
u/ottawadeveloper Oct 13 '26
they're useful when a lot of values are null or a default value, then you can get get with a default or a defaultdict to save on memory.
I've used it for caching recently - I was loading a value with x y z coordinates from a grid in a file too big to be in memory. Under the hood I think functools caching methods use this too.