[Python-3000] Type annotations: annotating generators

Edward Loper edloper at gradient.cis.upenn.edu
Sun May 21 20:51:57 CEST 2006


On May 21, 2006, at 2:23 PM, Collin Winter wrote:
> This is something I've been meaning to bring up: if we're serious
> about the "tuples = fixed-length collections, lists = unknown-length
> collections" distinction, then the CPython core should switch over to
> this mindset as well.

Although lists are *often* used for unknown-length ordered homogenous  
collections, and tuples are *often* used for fixed-length  
heterogeneous collections, I think it would be a mistake to try to  
define them this way.  In particular, there is at least one other  
important difference between tuples and lists: mutability.  If you  
need to use an unknown-length sequence as a key, then it's very  
natural to use a tuple.  And if you want a fixed-length heterogeneous  
collection that's mutable, then it's natural to use a list.

-Edward



More information about the Python-3000 mailing list