[Cython] __dealloc__ generation, please comment this ...
Robert Bradshaw
robertwb at math.washington.edu
Wed Feb 25 04:49:39 CET 2009
On Feb 24, 2009, at 6:59 PM, Lisandro Dalcin wrote:
> AFAIK, cdef classes can only have one base, right? This would let us
> get rid of module-global types at deallocators... Am I missing
> something?
Yes, you're missing two things. First, the deallocation needs to call
up the chain. Suppose We have classes A -> B -> C. Then if o is of
type C, Py_TYPE(o)->tp_base will always be B. What one needs to do is
have C's deallocator call B's, and B's deallocator call A.
Second, this would slow down deallocation of every object (which
happens a lot), which IMHO is more important.
Also, it's not enough to make the deallocator safe, one would need to
make any code that can be called by any deallocator safe.
> diff -r edbbb70369d7 Cython/Compiler/ModuleNode.py
> --- a/Cython/Compiler/ModuleNode.py Tue Feb 24 21:31:02 2009 -0300
> +++ b/Cython/Compiler/ModuleNode.py Tue Feb 24 23:53:26 2009 -0300
> @@ -943,7 +943,7 @@
> if base_type:
> tp_dealloc = TypeSlots.get_base_slot_function(scope,
> tp_slot)
> if tp_dealloc is None:
> - tp_dealloc = "%s->tp_dealloc" %
> base_type.typeptr_cname
> + tp_dealloc = "Py_TYPE(o)->tp_base->tp_dealloc"
> code.putln(
> "%s(o);" % tp_dealloc)
> else:
>
>
> --
> Lisandro Dalcín
> ---------------
> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
> Tel/Fax: +54-(0)342-451.1594
> _______________________________________________
> Cython-dev mailing list
> Cython-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/cython-dev
More information about the Cython-dev
mailing list