[Python-ideas] Suggested MapView object (Re: __len__() for map())

Paul Moore p.f.moore at gmail.com
Tue Dec 11 07:53:38 EST 2018

On Tue, 11 Dec 2018 at 11:49, E. Madison Bray <erik.m.bray at gmail.com> wrote:
> The idea would be to now enhance the existing built-ins to restore at
> least some previously lost assumptions, at least in the relevant
> cases.  To give an analogy, Python 3.0 replaced range() with
> (effectively) xrange().  This broken a lot of assumptions that the
> object returned by range(N) would work much like a list, and Python
> 3.2 restored some of that list-like functionality by adding support
> for slicing and negative indexing on range(N).  I believe it's worth
> considering such enhancements for filter() and map() as well, though
> these are obviously a bit trickier.

Thanks. That clarifies the situation for me very well.

I agree with most of the comments you made, although I don't have any
good answers. I think you're probably right that Guido's original idea
to move map and filter to functools might have been better, forcing
users to explicitly choose between a genexp and a list comprehension.
On the other hand, it might have meant people used more lists than
they needed to, as a result.


More information about the Python-ideas mailing list