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

Jonathan Fine jfine2358 at gmail.com
Wed Nov 28 10:52:17 EST 2018


Suppose itr_1 is an iterator. Now consider

    itr_2 = map(lambda x: x, itr_1)
    itr_3 = itr_1

We now have itr_1, itr_2 and itr_3. There are all, effectively, the
same iterator (unless we do an 'x is y' comparision).

I conclude that this suggestion amounts to have a __len__ for ANY
iterator, and not just a map. In other words, this suggestion has
broader scope and consequences than were presented in the original
post.

-- 
Jonathan


More information about the Python-ideas mailing list