In Python you never free memory by hand. Objects appear when you make them, and disappear when nothing needs them any more. The rule behind that is simple, and CPython’s main way of applying it is reference counting. Knowing the rule explains when a file is closed, when a destructor runs, why a list can keep a huge object alive, and why a cycle needs extra help, which the next lesson provides.
More lessons in Complete Python Programming