Let’s say I have class A(<class ...>): pass. Should I be explicitly calling del for a deep delete? Let me be more specific: What happens just before a fork merge with a current thread? When a thread is being interwoven with another, does it thrash or use a pointer?
EDIT
The
delkeyword doesn’t actually explicitly remove an object. It decrements the reference count, and then the garbage collector cleans up the memory if nothing else is using it. It’s useful when you have a block of code that will be running for a long time, and a variable that’s eating up a lot of memory that you don’t need anymore.Once you exit the scope of a function, all variables will have their reference count decremented (and cleaned up if appropriate). There is nothing deep or special about an explicit call to
del.Oh I should also mention that the
delcommand removes the variable name from the local scope. So from your point of view the variable is gone. However if other things are referencing the object being pointed to, the memory itself will not be cleaned up (yet).EDIT
Forks don’t merge. You can
waiton a fork to exit, but that’s it. And when youjoinanother thread, they aren’t being merged there either. They have different stacks (but the same heap). When a thread ends, all variables within that thread’s scope have their reference count decremented (and cleaned up if appropriate). I don’t understand you question about thrashing and pointers — I have no idea what thrashing means, and python doesn’t have pointers.