[Python-Dev] PEP 0424: A method for exposing a length hint
Steven D'Aprano
steve at pearwood.info
Sun Jul 15 15:47:07 CEST 2012
More information about the Python-Dev mailing list
Sun Jul 15 15:47:07 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 ]
Antoine Pitrou wrote: > The point is that 0 is a legitimate value for a length hint. Simple > implementations of __length_hint__ will start returning 0 as a > legitimate value and you will wrongly interpret that as "don't know", > which kinds of defeat the purpose of __length-hint__ ;) > That said, I don't think a special value for "is infinite" is useful. > Just make -1 mean "I don't know". You've obviously never accidentally called list on an infinite iterator *wink* It's not the (eventual) MemoryError that is the problem. On some systems, this can cause the PC to become unresponsive as the OS tries to free an ever-increasing amount of memory. Been there, done that, on a production system. I had to do a hard reboot to fix it. I think having a hint that says "there's no way this can succeed, fail immediately" is more useful than caring about the difference between a hint of 0 and a hint of 1. -- Steven
- 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