object reincarnation

alex23 wuwei23 at gmail.com
Thu Jun 11 03:20:57 EDT 2009


On Jun 11, 5:34 am, Manavan <manava... at gmail.com> wrote:
> Since the real world objects often needs to be deleted even if they
> have some reference from some other object [...]

>From this it sounds like you're trying to implement some form of weak
referencing. Are you familiar with weakref?

"A weak reference to an object is not enough to keep the object alive:
when the only remaining references to a referent are weak references,
garbage collection is free to destroy the referent and reuse its
memory for something else. A primary use for weak references is to
implement caches or mappings holding large objects, where it’s desired
that a large object not be kept alive solely because it appears in a
cache or mapping."

http://docs.python.org/library/weakref.html



More information about the Python-list mailing list