It is best practice to never rely on a garbage collector to collect an object that monitors a limited resource in a timely manner. This may delay the collection of any particular garbage indefinitely. You do not want to leave the file open for the garbage collector to clean up, because there is a limit to the number of files that you can open right away.
It happens that the Python garbage collector has a reference counter and frees objects without links for free, but this is a detail of the implementation. If you use another implementation, such as PyPy or IronPython, this does not apply. I had a break in the program when I moved it to another implementation because I inadvertently relied on counting Python links to clean up resources. In addition, you may encounter errors that occur because you accidentally created a loop somewhere.
I do not know any best practices for widgets. I did not think that I should clean them. If the widget has a window associated with it, this is an OS handle that you should theoretically clean up. Usually only GtkWindow will have a real window, but it is possible that your plugin will create a widget with a window. So, I would say that in this particular unlikely event, you should theoretically destroy the widget. Otherwise, it is great to destroy them manually if you do not need them, but I would say do not do this to do this.
source share