Reference count access or better method?

Philip Swartzleonard starx at pacbell.net
Sun Jan 13 23:23:08 CET 2002


It's hard to describe this in a subject line, but...

I have a class. When the class is instiantated, it requires a name, and 
'registers' itself in a module level name->object dictionary. It is then 
used by other objects, which should keep a local reference if they need 
continual access. When no one else but the dictionary refernces the 
object, i want to have the _option_ to purge it (just giving up on it and 
deleting it from the dict is not what i want, it must have a reference 
there for as long as it is). To determine this 'purgable' status, the 
best option i've come up with is to check the reference count, and if 
it's at one and we have a referece, we have the only one, therefore it's 
purgable. However, the only thing i've found that acesses refrence counts 
is the referer list in the GC module, and using that seems kind of 
hackey.

Is weekref what i want for something like this? Is there a better way to 
design it in general? (FWIW, i'm currently planning to do this with 
textures and 3d objects (two sets))

Thanks!

-- 
Philip Sw "Starweaver" [rasx] :: "Something a little bit like blue"



More information about the Python-list mailing list