[Python-Dev] PEP 0424: A method for exposing a length hint
Ethan Furman
ethan at stoneleaf.us
Mon Jul 16 21:59:20 CEST 2012
More information about the Python-Dev mailing list
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]).__length_hint__() return? 3 or unknown? > If 3, then the semantics of l=[1,2,3]; l += iter(l) will change > (infinite loop without __length_hint__ vs. list of 6 elements with __length_hint__). 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 ]
More information about the Python-Dev mailing list