Dan Roberts wrote:
>
> Thanks for the reply. Of course you're right, Py_DECREF() might cause
> infinite recursion. (At least the docs say Py_DECREF() calls
> tp_dealloc when the refcount reaches 0) I'm a bit confused as to why
> we manipulate the refcount at all. Since this is the dealloc method
> isn't the refcount 0 already? And the object is freed at the end of
> the method unconditionally too, so there's no chance of resurrection,
> right?
>
> I realize I might be missing some important CPython implementation
> details (I try to look them up before I blurt everything out at least)
> so I appreciate that you guys are humoring my questions.
>
If this is what I'm thinking it is:
def printsomething(x):
y = x # incref from 0 to 1
print y
# here, decref y => infinite recursion
cdef class A:
cdef __dealloc__(self):
# refcount of self is 0 (without workaround)
printsomething(self)
Dag Sverre
> Thanks,
> Dan
>
>> On May 12, 2010 8:25 PM, "Robert Bradshaw"
>> <[email protected] <mailto:[email protected]>>
>> wrote:
>>
>> On May 12, 2010, at 5:44 PM, Dan Roberts wrote:
>> > While we're talking about this sort of thing, in C...
>>
>> Py_DECREF checks to see if the refcount is 0 and if so invokes the
>> deallocation methods. This is in the deallocation method, so we
>> wouldn't want that. (The refcount is temporarily bumped up so that it
>> doesn't go to 0 while executing the body of the function.)
>>
>>
>> > Cheers,
>> > Dan
>> >
>> > P.S. What would be the ideal way for me to contribute things back in
>> > the fu...
>>
>> Yes, that would work well. You could also post patches to
>> http://trac.cython.org/cython_trac
>> (just send one of us an htpasswd entry offlist for an account).
>>
>>
>> >
>> >>
>> >> >
>> >> > On May 9, 2010 3:49 AM, "Stefan Behnel" <[email protected]
>> <mailto:[email protected]>>
>> >> wrote:
>> >> >
>> >> > ...
>>
>> > _______________________________________________
>> > Cython-dev mailing list
>> > [email protected]...
>>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
>
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev