__del__ and python classes

How could I write Python for 12 years without knowing this?

Objects that have __del__() methods and are part of a reference cycle cause the entire reference cycle to be uncollectable, including objects not necessarily in the cycle but reachable only from it.

Well, I guess that never having __del__ work the way I thought it did has saved me from many nasty memory leaks.  And learning about this has solved another one.  I guess there’s always something new to learn.

Leave a Reply