What Del Actually Deletes
CPython manages memory with reference counting: every object carries a count of how many references point to it, and CPython deallocates the object the instant that count reaches zero.
class Loud:
def __del__(self):
print("destroyed")
a = Loud()
b = a
del a
print("after del a")
del b
print("after del b")
What does this print, in order?
Sign in to answer questions and track your progress
Sign In