At today's sprint, Brian Holmes contributed a patch that implements
zip as an interator, a la izip. When reviewing Brian's code, I noticed
that he added an implementation of __length_hint__. My gut feeling is
that this isn't particularly useful given that zip() is almost
exclusively used iteratively, and rarely if ever converted to a list
or a tuple. (The one common exception is in the test suite, but there
it's almost always a short list, and 3 out of 5 were actually tests
for zip or izip.)

Should we rip it out or keep it?

Also, the existing convention for calling __length_hint__ (e.g. in
_PyObject_LengthHint() in abstract.c) seems to be to use
PyObject_CallMethod() and suppress TypeError and AttributeError coming
out of the call. It would seem to make much more sense to check
whether the attribute exists without calling it, and once it exists,
just call it and not suppress any exceptions that come out of it. Is
there any reason why this shouldn't work?

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
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

Reply via email to