non-owning references?

Utpal Sarkar doetoe at gmail.com
Fri Jul 24 08:38:00 EDT 2009


Hi,

I'm not sure the subject describes what I'm looking for, but the
question is the following:
Is there a way I can tell a variable that the object it is pointing
too is not owned by it, in the sense that if it is the only reference
to the object it can be garbage collected?
I want this for what is essentially a singleton class, so that on
first instantiation the object is created and a reference is kept in
the class, that is used to return the same object in subsequent
instantiations. When all instances go out of scope, the reference in
the class is still there, preventing it from being garbage collected,
but since the instance can be huge, I would like it to be.

Thanks,

Utpal



More information about the Python-list mailing list