[Python-ideas] Variable-length, homogeneous tuple: why?
Terry Reedy
tjreedy at udel.edu
Sun Aug 17 10:51:46 CEST 2014
On 8/17/2014 4:23 AM, Ben Finney wrote:
> 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.
There are also fixed-length homogeneous structures, like points.
> Why? What real-world uses are there, where a list won't do the job
> adequately?
Variable-length homogenous tuples are part of python syntax in multiple
places.
Tuples can be hashed and put in sets an used as dict keys, lists cannot.
Tuple contants are calculated just once when the code is compiled (and
typically saved as .pyc).
--
Terry Jan Reedy
More information about the Python-ideas
mailing list