How does Python (2.6.4, specifically) determine list membership in general? I\'ve run some tests to see what it does:
def main():
obj = fancy_obj(arg=\'
Here is code from the Python SVN:
static int
list_contains(PyListObject *a, PyObject *el)
{
Py_ssize_t i;
int cmp;
for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(a); ++i)
cmp = PyObject_RichCompareBool(el, PyList_GET_ITEM(a, i),
Py_EQ);
return cmp;
}
so basically it uses the ==
with the object and each object in the list.