Changes between Version 1 and Version 2 of Ticket #14711, comment 31


Ignore:
Timestamp:
09/28/13 23:02:03 (6 years ago)
Author:
SimonKing
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #14711, comment 31

    v1 v2  
    1010We want that a strong reference [edit: I mean an external strong reference] to Q keeps phi alive. Well, it does, since we added a strong reference Q->phi.
    1111
    12 We want that phi can be collected, if no external strong reference to Q exists. Well, there only are weak references from the `MonoDict` to phi and to Q. Hence, the only strong reference to phi comes from Q, and the only strong reference to Q comes from phi. This is a circle, that Python's cyclic garbage collector can deal with. Both Q and phi would be collected, and removed from the `MonoDict`.
     12We want that phi can be collected, if no external strong reference to Q [edit: or to phi] exists. Well, there only are weak references from the `MonoDict` to phi and to Q. Hence, the only strong reference to phi comes from Q, and the only strong reference to Q comes from phi. This is a circle, that Python's cyclic garbage collector can deal with. Both Q and phi would be collected, and removed from the `MonoDict`.
     13
     14[edit:] And finally: An external strong reference to phi will keep Q alive, since we have a strong reference from phi to its domain Q.
    1315
    1416I find this solution by far more appealing than introducing a weak reference to the domain of a map. Good night.