static PyObject *
cmp_outcome(int op, register PyObject *v, register PyObject *w)
{
int res = 0;
switch (op) {
case PyCmp_IS:
res = (v == w);
break;
case PyCmp_IS_NOT:
res = (v != w);
break;
In [1]: def bar(self, x): ...: return self.x + y ...: In [2]: class Foo(object): ...: x = 9 ...: def __init__(self ,x): ...: self.x = x ...: bar = bar ...: In [3]: foo = Foo(5) In [4]: foo.bar is Foo.bar Out[4]: False In [5]: id(foo.bar) == id(Foo.bar) Out[5]: True
In [7]: dis.dis("id(foo.bar) == id(Foo.bar)")
0 BUILD_MAP 10340
3 BUILD_TUPLE 28527
6 <46>
7 DELETE_GLOBAL 29281 (29281)
10 STORE_SLICE+1
11 SLICE+2
12 DELETE_SUBSCR
13 DELETE_SUBSCR
14 SLICE+2
15 BUILD_MAP 10340
18 PRINT_EXPR
19 JUMP_IF_FALSE_OR_POP 11887
22 DELETE_GLOBAL 29281 (29281)
25 STORE_SLICE+1
In [8]: dis.dis("foo.bar is Foo.bar")
0 BUILD_TUPLE 28527
3 <46>
4 DELETE_GLOBAL 29281 (29281)
7 SLICE+2
8 BUILD_MAP 8307
11 PRINT_EXPR
12 JUMP_IF_FALSE_OR_POP 11887
15 DELETE_GLOBAL 29281 (29281)
print id(foo.bar) == id(foo.__init__)
fb = foo.bar Fb = Foo.bar print id(fb) == id(Fb)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有