Python Forum
incremental testing in all()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
incremental testing in all()
#5
Everyone has access not only 'equivalent' but also 'exact' code.

Go to https://github.com/python/cpython/blob/m...inmodule.c and look for builtin_all. For your convenience it's provided below (I am not C-man myself so I have no idea what does it mean Smile ):

static PyObject *
builtin_all(PyObject *module, PyObject *iterable)
/*[clinic end generated code: output=ca2a7127276f79b3 input=1a7c5d1bc3438a21]*/
{
    PyObject *it, *item;
    PyObject *(*iternext)(PyObject *);
    int cmp;

    it = PyObject_GetIter(iterable);
    if (it == NULL)
        return NULL;
    iternext = *Py_TYPE(it)->tp_iternext;

    for (;;) {
        item = iternext(it);
        if (item == NULL)
            break;
        cmp = PyObject_IsTrue(item);
        Py_DECREF(item);
        if (cmp < 0) {
            Py_DECREF(it);
            return NULL;
        }
        if (cmp == 0) {
            Py_DECREF(it);
            Py_RETURN_FALSE;
        }
    }
    Py_DECREF(it);
    if (PyErr_Occurred()) {
        if (PyErr_ExceptionMatches(PyExc_StopIteration))
            PyErr_Clear();
        else
            return NULL;
    }
    Py_RETURN_TRUE;
}
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
incremental testing in all() - by Skaperen - Aug-15-2019, 11:47 PM
RE: incremental testing in all() - by Skaperen - Aug-17-2019, 04:15 AM
RE: incremental testing in all() - by buran - Aug-17-2019, 06:01 AM
RE: incremental testing in all() - by Skaperen - Aug-18-2019, 07:10 PM
RE: incremental testing in all() - by perfringo - Aug-17-2019, 07:12 AM
RE: incremental testing in all() - by Gribouillis - Aug-17-2019, 07:36 AM
RE: incremental testing in all() - by buran - Aug-18-2019, 07:25 PM
RE: incremental testing in all() - by Skaperen - Aug-18-2019, 07:59 PM
RE: incremental testing in all() - by DeaD_EyE - Aug-18-2019, 11:36 PM
RE: incremental testing in all() - by Skaperen - Aug-19-2019, 06:18 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020