[Python-Dev] PEP 0424: A method for exposing a length hint (original) (raw)
Ethan Furman ethan at stoneleaf.us
Mon Jul 16 21:59:20 CEST 2012
- Previous message: [Python-Dev] PEP 0424: A method for exposing a length hint
- Next message: [Python-Dev] PEP 0424: A method for exposing a length hint
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
M Stefan wrote:
Also, what would iter([1,2,3]).lengthhint() return? 3 or unknown? If 3, then the semantics of l=[1,2,3]; l += iter(l) will change (infinite loop without lengthhint vs. list of 6 elements with lengthhint).
What length_hint returns is irrelevant -- it's only a hint. Python will have to loop over all the items. So you would still get an infinite loop with the above code.
Ethan
- Previous message: [Python-Dev] PEP 0424: A method for exposing a length hint
- Next message: [Python-Dev] PEP 0424: A method for exposing a length hint
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]