不,
is是直接指针比较,
id只是将转换为的对象地址返回
long。
来自
ceval.c:
case PyCmp_IS: res = (v == w); break;case PyCmp_IS_NOT: res = (v != w); break;
v和
w这里简单
PyObject *。
来自
bltinmodule.c:
static PyObject *builtin_id(PyObject *self, PyObject *v){ return PyLong_FromVoidPtr(v);}PyDoc_STRVAR(id_doc,"id(object) -> integern\nReturn the identity of an object. This is guaranteed to be unique amongnsimultaneously existing objects. (Hint: it's the object's memory address.)");
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)