Tim Daneliuk <i...@tundraware.com>:
> Are you saying that each time a,b,c are reassigned to new instances of
> SomeObject the old instance counts go to 0 and are immediately - as in
> synchronously, right now, on the spot - removed from memory?
That depends on the implementation of Python. CPython employs reference
counting so the answer to your question is often yes. Objects that
participate in reference cycles, cannot be cleared on the spot. They
have to wait for a GC analysis.
> My understanding was (and I may well be wrong), that the reference
> count does get decremented - in this case to 0 - but the *detection*
> of that fact does not happen until the gc sweep looks through the heap
> for such stale objects.
You are confusing two mechanisms. The reference count mechanism kicks in
right away when 0 is reached. The sweep method doesn't make any use of
There are also Python implementations that don't make any use of