Re: [Cython] Hooking tp_clear()

2019-01-10 Thread Jeroen Demeyer
On 2019-01-09 22:12, Stefan Behnel wrote: I would like to avoid adding Cython specific features that are better served by the general finalisation mechanism of PEP-442. That could also be used as argument against @cython.no_gc_clear but we still have that anyway. Second, with PEP-442 you don

Re: [Cython] Hooking tp_clear()

2019-01-09 Thread Stefan Behnel
Jeroen Demeyer schrieb am 09.01.19 um 15:43: > (reviving this thread after I thought about it some more...) > > As I mentioned in the original post, I want something like __dealloc__ but > with access to a particular cdef attribute (representing a Python object). > Since Python attributes of cdef

Re: [Cython] Hooking tp_clear()

2019-01-09 Thread Jeroen Demeyer
(reviving this thread after I thought about it some more...) As I mentioned in the original post, I want something like __dealloc__ but with access to a particular cdef attribute (representing a Python object). Since Python attributes of cdef classes may have been cleared by tp_clear, they can

Re: [Cython] Hooking tp_clear()

2018-09-07 Thread Stefan Behnel
Jeroen Demeyer schrieb am 07.09.2018 um 10:14: > On 2018-09-07 06:35, Stefan Behnel wrote: >> Maybe you actually want "tp_finalize"? >> >> https://www.python.org/dev/peps/pep-0442/ >> >> Cython moves "__del__" methods there in Py3.4+. > > First of all, are you sure? I tried to cythonize > > cdef

Re: [Cython] Hooking tp_clear()

2018-09-07 Thread Jeroen Demeyer
On 2018-09-07 06:35, Stefan Behnel wrote: Maybe you actually want "tp_finalize"? https://www.python.org/dev/peps/pep-0442/ Cython moves "__del__" methods there in Py3.4+. First of all, are you sure? I tried to cythonize cdef class X: def __del__(self): pass but the generated C c

Re: [Cython] Hooking tp_clear()

2018-09-06 Thread Greg Ewing
Jeroen Demeyer wrote: I have a concrete use case where I want something like __dealloc__ but > *before* Python attributes are cleared. So this really belongs in tp_clear(). Are you sure you can't do it in __del__? From what I gather, the presence of __del__ no longer prevents cyclic garbage c

Re: [Cython] Hooking tp_clear()

2018-09-06 Thread Stefan Behnel
Jeroen Demeyer schrieb am 06.09.2018 um 22:54: > Cython's __dealloc__ special method is meant to deal with cleaning up > instances of cdef classes. However, this hooks tp_dealloc() and does not > have meaningful access to Python attributes, since those might have been > cleared by tp_clear(). > >