Title: builtin map iterator should provide __length_hint__
Type: enhancement Stage: resolved
Components: Interpreter Core Versions:
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: nmusolino, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2019-06-27 20:12 by nmusolino, last changed 2019-06-27 21:28 by nmusolino. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14432 open nmusolino, 2019-06-27 20:30
Messages (3)
msg346772 - (view) Author: Nicholas Musolino (nmusolino) * Date: 2019-06-27 20:12
The builtin `map` function takes one or more user-supplied iterators, and returns an iterator.

When all the user-supplied iterator arguments to `map` provide a valid length hint (according to the PEP 424 length hint protocol), the iterator returned by `map` should provide a length hint.  

I suggest the following behavior:  when all the iterator arguments provide a valid length hint, the map iterator should return the minimum value among all length hint values, because it stops upon exhaustion of the shortest input iterator.

If any user-supplied iterator does *not* provide a length hint according to the PEP 424 protocol, the map iterator should return the `NotImplemented` singleton, in accordance with the protocol.

When the evaluation of `__length_hint__()` for a user-supplied iterator raises an exception, the exception should be propagated by the map iterator's `__length_hint__()` method.
msg346774 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-27 20:31
This is a duplicate of issue26828.
msg346776 - (view) Author: Nicholas Musolino (nmusolino) * Date: 2019-06-27 21:08
Thanks, Serihy.  I can close this issue.

I actually have been looking at this problem for some time, and created a patch, but don't what the "length transparency issues" that led to #26828 being closed.  

Do you think I should close this and comment on the original issue?
Date User Action Args
2019-06-27 21:28:35nmusolinosetstatus: open -> closed
stage: patch review -> resolved
2019-06-27 21:08:04nmusolinosetmessages: + msg346776
2019-06-27 20:31:50serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg346774
2019-06-27 20:30:19nmusolinosetkeywords: + patch
stage: patch review
pull_requests: + pull_request14248
2019-06-27 20:12:36nmusolinocreate