reference counting for garbage collection
Jason Orendorff
jason at jorendorff.com
Mon Dec 10 15:33:31 EST 2001
More information about the Python-list mailing list
Mon Dec 10 15:33:31 EST 2001
- Previous message (by thread): reference counting for garbage collection
- Next message (by thread): reference counting for garbage collection
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Paul Brian" <paul1brian at yahoo.com> wrote: > I am getting confused over object references/pointers etc.... Relax. It's easier than you think (I think). > [...] will the function foo still keep some reference to conn > such that del(x) will *not* destroy conn but conn will still > stay alive? Nope. As long as you have a variable somewhere by which you could ever possibly reach that connection object and use it, ever again ever, Python keeps the object alive. But when your function exits, all its local variables go away. After you've lost every possible way to reach an object, Python is likely to kill it. After all, the reasoning goes, you clearly won't be using it anymore. If you want Python to keep an object alive, just stash it someplace where you can get to it later - in a global list, for example. > what have I done wrong in the stuff I just wrote (no not the above:-)? There's no telling. <wink> -- Jason Orendorff http://www.jorendorff.com/
- Previous message (by thread): reference counting for garbage collection
- Next message (by thread): reference counting for garbage collection
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list