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
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com