为什么键入可变长度元组需要省略号而列表不需要?

Why does typing variable length Tuple require ellipses but List does not?

根据 docs:

To specify a variable-length tuple of homogeneous type, use literal ellipsis, e.g. Tuple[int, ...]. A plain Tuple is equivalent to Tuple[Any, ...], and in turn to tuple.

因此,注解Tuple[int]指定了一个包含单个整数的元组;然而 List[int] 意味着可变长度。

为什么 ... 必须与 Tuple[int, ...] 一起使用而不是与 List[int] 一起使用,如果两者都可以是 homeo/hetero-geneous?

元组通常用于固定大小的小型异构值集。因此,类型提示采用单独的参数来表示每个值的类型,例如Tuple[str, int, list]。同构元组实际上是一种特殊情况,... 符号是它的 shorthand。

列表通常是未定义长度的同构序列。因此它的类型提示只接受一个参数。