Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardPythonrefcounting and cyclic GCSingle-choice MCQ

With the cycle below and the cyclic collector explicitly invoked, what happens to the two objects and their __del__ methods in CPython 3.4+?

import gc gc.disable() class Node: def __del__(self): print('__del__ ran') a = Node(); b = Node() a.ref = b; b.ref = a del a; del b n = gc.collect() print('collected:', n)