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.
精彩评论