reference counter and __del__

shindich at my-deja.com shindich at my-deja.com
Mon Jul 10 21:23:45 EDT 2000


In article <3969CB5C.A860D124 at muc.das-werk.de>,
  thiele at muc.das-werk.de wrote:
> 1. I have the problem that not all of my objects are destroyed and I
> don't know where and why, so I wonder if there a way to check out from
> where and how many references to a special object exists?
>
You can use sys.getrefcount ().
Thomas Thiele posted a similar question today, you might want to look at
the answers to that posting too. For all we know, there could be a
reference leak in pickle.
> 2. When __del__ is called the object will be detroyed, correct?
Yep. In fact, __del__ is called as the object being destroyed.
> 3. Why is __init__ not called when I unpickle an object?
>
I don't know the exact answer to this question, but my guess is that it
doesn't need to call the constructor. I assume that pickle.loads ()
simple creates an object and sets up the properties on that object to be
the same as those of the object that got serialized using
pickle.dumps().
But read the docs on it. I am no authority on pickle inetrnals.
> Thomas
>

Alex Shindich
http://www.shindich.com/


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list