STINNER Victor added the comment: > But note that map() and zip() take several iterables, and we should call > __length_hint__() for every of them (unless found a one with not implemented > __length_hint__()). This can slow down the execution for short sequences.
Oh, there is no slot for __length_hint__(). Maybe we should also try to add a new slot for it? Maybe we can use a fast-path for the most common cases like list(map(func, list))? > It is impossible to implement reasonable filter.__length_hint__(), because > the length of resulting sequence can be from 0 to the length of the input > sequence, and returning the maximal value would be not correct. What I see is that Python 2 is much faster and Python 2 reallocates N items if the input sequence contains N items. But yeah, we have to benchmark such change on Python 3 ;-) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26828> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com