Reputation:
l = [1, 2, 3]
del l
From the python docs:
It is not guaranteed that
__del__()
methods are called for objects that still exist when the interpreter exits.
Does this mean that the list object, in this case l
, will not be deleted even when the interpreter exits? I mean when the program exits, aren't all the objects reclaimed?
Upvotes: 4
Views: 97
Reputation: 24134
It is not guaranteed that
__del__()
methods are called for objects that still exist when the interpreter exits.
This statement implies that you should not rely on a custom __del__()
method being executed upon interpreter exit.
The statement does not imply that the interpreter will create a memory leak.
In all cases when Python exits, all memory will be released.
Upvotes: 3