On Mon, Jan 9, 2017 at 3:08 PM, Jean-Pierre Flori <jpfl...@gmail.com> wrote:
> > > On Monday, January 9, 2017 at 7:03:57 PM UTC+1, Volker Braun wrote: >> >> On Monday, January 9, 2017 at 4:45:19 PM UTC+1, Jean-Pierre Flori wrote: >>> >>> You can just use the Python "del" operator and Cython should translate >>> it to a destructor call. >>> >> >> No, there is the following caveat when cyclic Python references are >> involved: >> >> __dealloc__ is always called, but there is no guarantee that pure Python >> attributes are still set (they may be cleared, that is, set to None, in >> order to break cycles). Cython (cdef) attributes are still set. >> >> __del__ will not always be called, some garbage objects are skipped to >> break cycles. If __del__ is being called then all Python attributes are >> still set. >> >> TLDR: use __dealloc__ to destroy wrapped C++ objects. >> > I meat write with __dealloc__: > cdef __dealloc__: > blablabla > .... > if I_made_sure_new_was_called_and_constructor_got_called: > del my_cdefed_c++_pointer_which_has_been_allocated_with_new > > Isn't that the correct way to trigger Cytohn writin down an explicit call > to the destructor? > Yes. If you use sig_malloc you should use sig_free instead. Note also that it's def __dealloc__ not cdef __dealloc__, since __dealloc__ is a Python special method. David > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at https://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.