I understand Python GC works in two ways:
1) Basic reference counting - below "John" has reference count of zero when "name" set to "Tom"
name = "John"
name = "Tom" (Reference count zero for "John")
2) Detect Circular References (Islands of Isolation). "GC" works at in-deterministic time (or if you invoke gc.collect() which isn't recommended).
Now, My question is, for (1), when name set to "Tom", "John" isn't collected immediately as soon as name = "Tom" right? GC would just mark "John" as un-reacheable and thus ready for collection (Which will happen later).
My understanding correct? Thanks
Reference:
https://rushter.com/blog/python-garbage-collector/
https://pythoninternal.wordpress.com/2014/08/04/the-garbage-collector/