Question about garbage collection

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Jan 16 20:01:54 EST 2024


On 17/01/24 1:01 am, Frank Millman wrote:
> I sometimes need to keep a reference from a 
> transient object to a more permanent structure in my app. To save myself 
> the extra step of removing all these references when the transient 
> object is deleted, I make them weak references.

I don't see how weak references help here at all. If the transient
object goes away, all references from it to the permanent objects also
go away.

A weak reference would only be of use if the reference went the other
way, i.e. from the permanent object to the transient object.

-- 
Greg


More information about the Python-list mailing list