On 2018-12-06 01:36, Nils Bruin wrote:
Because the coercion map from A to
B is also stored on A, a strong reference to B exists.

No. The map will be referenced both from A and from B with one of those references weak and one of those references strong, without specifying a priori which one is strong and which one is weak.

That's the point of MultiWeakref: as long as we're not garbage collecting, it doesn't matter which reference is strong and which one is weak: only the numbers matter, since that determines the refcount. When garbage collecting, the tp_traverse algorithm of MultiWeakref decides dynamically which reference to consider weak and which strong in a way to maximize the amount of garbage that can be collected.

So let's assume that it's weakly referenced from A and strongly referenced from B. (The map will also be referenced from the coercion model, but always weakly; this won't change). Then we have a strong reference cycle from B to the map and back, which does not prevent garbage collection. So, if nothing else holds a reference to B, then both B and the map can be deleted.

Anyway, that's the idea. I haven't worked out all the details yet...

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to