[Python-3000] map() Returns Iterator

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Aug 4 14:33:16 CEST 2007


Jeffrey Yasskin wrote:
> <wild-speculation>
> Is it possible to make the result of map() look like a list if people
> are paying attention, but use memory like an iterator when they're
> not?

I suppose it could lazily materialise a list behind the
scenes when needed (i.e. on the first __getitem__ or
__len__ call), but the semantics still wouldn't be *exactly*
the same, as it wouldn't be possible to iterate over it more
than once. Also as any side-effects would be delayed.

--
Greg


More information about the Python-3000 mailing list