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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4