4 ms·
> This isn't C++ where we can tie that to a destructor `def __del__`
by lijok 2y ago
> This isn't C++ where we can tie that to a destructor
`def __del__`
- mjr00 2y agoC++ destructors are deterministic. Relying on a nondeterministic GC call to run __del__ is not good code. Also worth noting that the Python spec does not say __del__ must be called, only that it may be called after all references are deleted. So, no, you can't tie it to __del__.
- 12_throw_away 2y ago> def __del__ Nope, do not ever do this, it will not do what you want. You have no idea _when_ it will be called. It can get called at shutdown where the entire runtime environment is in the process of being torn down, meaning that nothing actually works anymore.