[Python-Dev] PEP czar for PEP 3144?

Guido van Rossum guido at python.org
Tue Mar 20 00:34:17 CET 2012


On Mon, Mar 19, 2012 at 3:44 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> I am not sure which way you are pointing, but the general default in 3.x is
> to return iterators: range, zip, enumerate, map, filter, reversed, open
> (file objects), as well at the dict methods.

Actually as I tried to say, the dict methods (keys() etc.) DON'T
return iterators. They return "views" which are iterable.

Anyway, I also tried to imply that it matters if the number of list
items would ever be huge. It seems that is indeed possible (even if
not likely) so I think iterators are useful.

> I am quite happy to be rid of
> the 'iter' prefix on the latter. This is aside from itertools. The main
> exceptions I can think of are str.split and sorted. For sorted, a list
> *must* be constructed anyway, so might as well return it. This apparently
> matches the case under consideration. If name differentiation is wanted,
> call it xxxlist.

Agreed, ideally you don't need to know or it'll be obvious from the
name without an explicit 'list' or 'iter'.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list