By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,941 Members | 1,753 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,941 IT Pros & Developers. It's quick & easy.

Re: deleting objects by finding all references and deleting?

P: n/a

"Jacob Davis" <j.************@gmail.comwrote in message
news:C6********************************** m...
| I read in some earlier messages that an object in Python is only
| removed or freed from memory when all references to that object have
| been deleted. Is this so?

A Python interpreter *may* delete an object when, but only when, it becomes
inaccessible from the currently running program. What interpreters do
depends on the interpreter.

| If so, is there a way to get all of the references to an object, so
| that they may all be deleted, thus actually deleting the object?

'References' are implementation details, not Python objects. So while in
CPython, sys.getrefcount(ob) returns a count, the meaning of 'get all
references' is not obvious.

So try to create, process, and delete objects as you go, and repeat for the
next, instead of create all, process all, and delete all. For CPython,
look at the gc module.


Jun 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.