Convert iterator __len__() methods to a private API.

This commit is contained in:
Raymond Hettinger 2005-09-24 21:23:05 +00:00
parent 9ceebd5445
commit 6b27cda643
16 changed files with 169 additions and 94 deletions

View file

@ -221,7 +221,7 @@ builtin_filter(PyObject *self, PyObject *args)
goto Fail_arg;
/* Guess a result list size. */
len = PyObject_Size(seq);
len = _PyObject_LengthCue(seq);
if (len < 0) {
if (!PyErr_ExceptionMatches(PyExc_TypeError) &&
!PyErr_ExceptionMatches(PyExc_AttributeError)) {
@ -873,7 +873,7 @@ builtin_map(PyObject *self, PyObject *args)
}
/* Update len. */
curlen = PyObject_Size(curseq);
curlen = _PyObject_LengthCue(curseq);
if (curlen < 0) {
if (!PyErr_ExceptionMatches(PyExc_TypeError) &&
!PyErr_ExceptionMatches(PyExc_AttributeError)) {
@ -2108,7 +2108,7 @@ builtin_zip(PyObject *self, PyObject *args)
len = -1; /* unknown */
for (i = 0; i < itemsize; ++i) {
PyObject *item = PyTuple_GET_ITEM(args, i);
int thislen = PyObject_Size(item);
int thislen = _PyObject_LengthCue(item);
if (thislen < 0) {
if (!PyErr_ExceptionMatches(PyExc_TypeError) &&
!PyErr_ExceptionMatches(PyExc_AttributeError)) {