3 ms·
The author's second article also contains information on how Python deals with circular references (a tracking garbage collector very similar to mark-and-sweep)
by lojack 13y ago
The author's second article also contains information on how Python deals with circular references (a tracking garbage collector very similar to mark-and-sweep).
http://patshaughnessy.net/2013/10/30/generational-gc-in-python-and-ruby http://patshaughnessy.net/2013/10/30/generational-gc-in-pyth...
It's also worth noting that you don't always need to deal with circular references in the case of short running programs. Additionally you can eliminate the possibility of ever creating a circular reference by using an immutable language.
- thinkpad20 13y agoSpeaking of immutable languages, there are actually tricks in Haskell by which it can actually generate circular references because of its laziness (ML, on the other hand, is immutable and strict, so it cannot, by default anyway). In regards to reference counting vs. garbage collection, one advantage to reference counting is that it can be more memory efficient, since objects do not unnecessarily accumulate in memory. It can be advantageous in embedded systems for this reason. GC can provide a speed boost at a memory usage cost, because `malloc` and `free` are relatively expensive, and using a garbage collector can reduce the number of these calls needed.