Basic Facts
- Lists are mutable (supporting inserts, appending etc.), Tuples are not
- Tuples are more memory efficient, and faster to iterate over
So it would seem their use-cases are clear. Functionally speaking, lists offer a superset of operations, tuples are more performant at what they do.
Observation
Most arrays that my team creates in the course of a program, are in fact, perfectly fine as immutable. We iterate over them, apply map, reduce, filter on them, may be insert into a database from them etc. all without insertion, popping or appending on the array-like-structure.
Question
Yet, a list seems to be not only the default (and only) choice among my developers, but seems even favoured by many library APIs to pass data around (like polars, tensorflow etc. which I use heavily).
And not even like using Tuples require some special skill, knowledge or understanding another-data-structure, it's really the same in terms of necessary syntax to subscript, or iterate.
What am I missing in the reasoning here?
typing
, anyway – tuples feel heterogeneous and lists homogeneous, which influences writing for readability.) – Adolescence