468,304 Members | 1,419 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,304 developers. It's quick & easy.

Re: deleting objects by finding all references and deleting?


"Jacob Davis" <j.************@gmail.comwrote in message
news:C6**********************************@gmail.co 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.

tjr

Jun 27 '08 #1
0 832

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by user | last post: by
6 posts views Thread by Matan Nassau | last post: by
9 posts views Thread by Aguilar, James | last post: by
161 posts views Thread by KraftDiner | last post: by
62 posts views Thread by ivan.leben | last post: by
7 posts views Thread by Gregor Kofler | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.