[Python-ideas] __len__() for map()

E. Madison Bray erik.m.bray at gmail.com
Wed Nov 28 10:05:50 EST 2018


On Wed, Nov 28, 2018 at 4:04 PM Steven D'Aprano <steve at pearwood.info> wrote:
>
> On Wed, Nov 28, 2018 at 03:27:25PM +0100, E. Madison Bray wrote:
>
> > I mostly agree with the existing objections, though I have often found
> > myself wanting this too, especially now that `map` does not simply
> > return a list.  This problem alone (along with the same problem for
> > filter) has had a ridiculously outsized impact on the Python 3 porting
> > effort for SageMath, and I find it really irritating at times.
>
> *scratches head*
>
> I presume that SageMath worked fine with Python 2 map and filter? You
> can have them back again:
>
> # put this in a module called py2
> _map = map
> def map(*args):
>     return list(_map(*args))
>
>
> And similarly for filter. The only annoying part is to import this new
> map at the start of every module that needs it, but while that's
> annoying, I wouldn't call it a "ridiculously outsized impact". Its one
> line at the top of each module.
>
> from py2 import map, filter
>
>
> What am I missing?

Large amounts of context; size of code base.


More information about the Python-ideas mailing list