Max Yuzhakov wrote:
Why for some instance __del__ called twice?
Such behaviour of __del__ seems to me unpredictable.
Here's a slightly modified version of your code. The 51st object destroyed
gets its __del__ method called twice. It doesn't matter how long your loop
is, every 50th object
Duncan Booth wrote:
As to why it happens, there is a mechanism in Python to stop unlimited
stack being used when objects are freed: when the stack gets too deep
then instead of being released, the Py_DECREF call puts the object
into a trashcan list and the objects aren't released until the
Duncan Booth wrote:
Duncan Booth wrote:
As to why it happens, there is a mechanism in Python to stop unlimited
stack being used when objects are freed: when the stack gets too deep
then instead of being released, the Py_DECREF call puts the object
into a trashcan list and the objects
Duncan Booth wrote:
DB I figured out what is going on in the code to deallocate an old-style
class
DB instance:
DB
DB The reference count is temporarily incremented.
DB
DB If the class has a __del__ method then a descriptor is created for the
DB method and called. When the call
Duncan Booth wrote:
DB BTW, the behaviour is completely different if you use a new style class,
DB but still somewhat bizarre: for new style classes only the first 25
objects
DB get freed when you clear a, the remainder are only released by the
garbage
DB collector.
If to add the
Duncan Booth wrote:
DB You should post a working code sample which generates your output if you
DB want a more useful answer.
Hello!
Today I have found a compact variant of a code which shows my question:
---
Hello!
It is correct behaviour for python to call __del__ on some
identity of a class object more than once?
In brief I shall describe a situation. Sorry for my english.
For debugin purposes I'm put in my module global counters
for counting __init__ and __del__ calls.
This is a sample code for
Max Yuzhakov writes:
MY print difference = %d % init_cnt-del_cnt
Little correction.
print difference = %d % (init_cnt-del_cnt)
--
GMT More Then ...
--
http://mail.python.org/mailman/listinfo/python-list
Max Yuzhakov wrote:
This is a sample code for clearness:
that code snippet doesn't create any foo() instances, what I can see...
/F
--
http://mail.python.org/mailman/listinfo/python-list
Max Yuzhakov wrote:
It is correct behaviour for python to call __del__ on some
identity of a class object more than once?
Not with the code which you gave as an example, but in the general case
yes, the only guarantee that Python gives about the __del__ method on an
instance is that it will
Duncan Booth пишет:
DB Not with the code which you gave as an example, but in the general case
DB yes, the only guarantee that Python gives about the __del__ method on an
DB instance is that it will be called zero, one or more than one times
during
DB the run of the program. In
11 matches
Mail list logo