I say let them leak? The only real risk (that I can see at least) is overflowing the refcount, and if I understand and remember an informal chat correctly even that is eliminated in newer Python versions where Py_None and friends have special deallocation which never deallocate...
Dag Sverre Seljebotn -----Original Message----- From: "Lisandro Dalcin" <[EMAIL PROTECTED]> Date: Wednesday, Oct 1, 2008 8:20 pm Subject: Re: [Cython] cython leaks references to Py_None for cdef'ed globals To: cython-dev <[email protected]>Reply-To: [email protected] BTW, this patch fix the issue by not initializing cdef'ed module >globals to None. But this is not the safest approach (I can imagine >some nasty ways to originate segfaults). Perhaps we should try to fix >the isue in FinalOptimizePhase.visit_SingleAssignmentNode > >On Wed, Oct 1, 2008 at 3:13 PM, Lisandro Dalcin <[EMAIL PROTECTED]> wrote: >> Consider the following code inside a one-line pyx file: >> >> cdef object someint = 7 >> >> Then Cython generates the following inside the module init function: >> >> /*--- Global init code ---*/ >> __pyx_v_9refleaks2_someint = Py_None; Py_INCREF(Py_None); >> >> /* "/u/dalcinl/Devel/Cython/sandbox/refleaks2.pyx":1 >> * cdef object someint = 7 # <<<<<<<<<<<<<< >> * >> */ >> Py_INCREF(__pyx_int_7); >> __pyx_v_9refleaks2_someint = __pyx_int_7; >> >> >> Clearly, Py_None references are being leaked. All this is because of >> bad interaction between this two methods: >> >> * ModuleNode.generate_global_init_code(...) (in ModuleNode.py) >> * FinalOptimizePhase.visit_SingleAssignmentNode(...) (in Optimize.py) >> >> >> >> -- >> 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 >> > > > >-- >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 [email protected] http://codespeak.net/mailman/listinfo/cython-dev
