[Python-ideas] Variable-length, homogeneous tuple: why? (was: Optional static typing -- the crossroads)
Ben Finney
ben+python at benfinney.id.au
Sun Aug 17 10:23:52 CEST 2014
Guido van Rossum <guido at python.org> writes:
> A mostly unrelated issue: there are two different uses of tuples, and
> we need a notation for both. One is a tuple of fixed length with
> heterogeneous, specific types for the elements; for example Tuple[int,
> float].
That's the meaning of a tuple data structure, to me.
> But I think we also need a way to indicate that a function expects (or
> returns) a variable-length tuple with a homogeneous element type.
Why? What real-world uses are there, where a list won't do the job
adequately?
I have encountered many uses of “homogeneous, variable-length sequence”
and every time a Python tuple is used for that, I perceive a Python list
would be better precisely *because* it better indicates that semantic
meaning.
I'd like to know how you think that's not true, and what real-world code
makes you think so.
--
\ “Contentment is a pearl of great price, and whosoever procures |
`\ it at the expense of ten thousand desires makes a wise and |
_o__) happy purchase.” —J. Balguy |
Ben Finney
More information about the Python-ideas
mailing list