On Tue, Jul 3, 2018 at 4:22 PM Simon King <simon.k...@uni-jena.de> wrote: > > On 2018-07-03, Jeroen Demeyer <j.deme...@ugent.be> wrote: > > On 2018-07-03 15:56, Simon King wrote: > >> This tuple is not weak-refable > > > > That's just a detail. We could easily implement a weakrefable tuple-like > > object. > > How? > > Let T be such object, corresponding to the tuple K1, K2. The reference > of D to T must be strong, for otherwise T would immediately be garbage > collected and thus the item that is keyed by T would be removed from D > immediately, even if K1 and K2 were permanent objects. Hence, in order to > avoid a strong reference chain to K1 and K2, the references from T to K1 > and K2 must be weak. > > So, T would basically be an ordinary tuple of weak references to > K1 and K2. These weak references should have a callback that does "del > D[T]" as soon as either K1 or K2 get collected. > > Hm. Would indeed be possible to implement.
Ah, that's even simpler than my implementation sketch, and makes just as much sense since we'd want to treat the entire container as only weakly-referenced if even one of its contained objects' refcount goes to zero. Yes, I think it would be possible as well. -- 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.