Why use a tuple instead of a list?
HiHe 174 Junior Poster
Recommended Answers
Jump to PostI'd use a tuple for heterogenous and/or fixed aggregates. Otherwise I'd use a list. Of course, there are always exceptions, but that's a generally universal guideline.
Jump to PostActually, tuples are mainly used by the Python language itself, for certain types of operations where lists would too slow, or where the immutability of tuples is helpful. For example, multiple return values are actually passed as a tuple, which can either be assigned as a single value or 'unpacked' …
Jump to PostA tuple uses much less memory than a list.
Jump to PostTuples, since they are immutable (can not be changed), are also useful for keys in a dictionary.
All 15 Replies
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster
Lardmeister 461 Posting Virtuoso
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
BearofNH 104 Posting Whiz
snippsat 661 Master Poster
BearofNH 104 Posting Whiz
snippsat 661 Master Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
snippsat 661 Master Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
sneekula 969 Nearly a Posting Maven
snippsat 661 Master Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.