开发者

GC in python: what will this behave?

A python class A:

a = A()
array.append(a)

... some operation triggers a's method b()

in a.b():

array.remove(self);
# will开发者_运维技巧 this make the self be freed? as the only reference has been removed from array.
# access the a's data...


While the method is executing, you still have a reference(self) to a .

Only once the method completes is a eligible for collection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜