Yes, please rip that
out. The patch should be a direct copy of the code in the itertools module. The use of length-hint was deliberately left-out of
izip().
Also, yes it would be fine to alter the
code in abstract.c to LBYL instead of suppressing exceptions.
Raymond
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/)
">
zip -> izip; is \_\_length\_hint\_\_ required?
Yes, please rip that
out. The patch should be a direct copy of the code in the itertools module. The use of length-hint was deliberately left-out of
izip().
Also, yes it would be fine to alter the
code in abstract.c to LBYL instead of suppressing exceptions.
Raymond
From: gvanrossum@gmail.com on behalf of Guido
van Rossum
Sent: Thu 8/24/2006 4:08 PM
To: Raymond
Hettinger; python-dev@python.org; Brian Holmes
Subject: zip ->
izip; is \_\_length\_hint\_\_ required?
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/)