2

In the context of doubly-linked lists, what are weakref's ref, proxy, ... good for, given that Python is able to detect cycles and garbage-collect them anyway?

I think I read that weakref was specifically created to break allocation cycles but is it still necessary to use it?

Ecir Hana
  • 10,864
  • 13
  • 67
  • 117
  • Note that there are other use cases for weakref. As [the documentation](http://docs.python.org/2/library/weakref.html) states, they can be used for creating caches or associating names to objects without maintaining the object alive after it has no other references (except for those in the cache). As for the usage of weakrefs in doubly-linked lists, you may want to check [this question](http://stackoverflow.com/questions/18068499/will-python-automatically-garbage-collect-doubly-linked-list). The short story is that while CPython *has* cycle detection, there are other implementations available – loopbackbee Oct 22 '13 at 14:44

0 Answers0