On Oct 16, 2008, at 1:00 AM, Dag Sverre Seljebotn wrote: > Lisandro Dalcin wrote: >> On Wed, Oct 15, 2008 at 5:31 PM, Dag Sverre Seljebotn >> <[EMAIL PROTECTED]> wrote: >>> Well, you seem to have a better grasp on this stuff than me so I'll >>> leave it for you :-) You are right, it is optimization stuff >>> going wrong >>> -- "entry.used" isn't honoured by the code in ModuleNode.py >>> initializing >>> the entries to Py_None. Just search for the comments inserted in the >>> .c-file at that point in ModuleNode.py and it will put you right on >>> track for where to insert the if-test. >> I believe I will push my original patch with a BIG comment about what >> is going one in Optimize.py > > Huh? Your patch doesn't solve this problem either? (I just > tried...fixnoneleaks.diff does nothing about the > > cdef object foo1 > > not being declared issue). > > The two should be orthogonal issues. I really believe that my patch > is how the first problem should be solved. Attaching now how I > believe the second problem should be solved, for which there seems > to be no patch yet anyway.
If foo1 is never used, it should never be delcared. This avoids a C warning in this case, and doesn't impact the operation of the module. > > If you agree I can simply make a push of my patches BTW, but > there's been holes in my patches before so I'm waiting. If you find > a way you think is better then feel free. > >> BTW, perhaps if we could support the --clenaup option as a compiler >> directive, then I would be able to write a rether good testcase. >> Do this request make sense, I mean, adding a 'cleanup' directive >> enabling the highest level of cleanup? I ALWAY build my code with >> cleanup enabled, so I would love to be hable to use in my preambles:: >> #cython: cleanup=True > > +1 > > But one should block its use as a decorator and with statement. > Perhaps a more descriptive name -- module_cleanup or similar? > > -- > Dag Sverre > diff -r 2dbb7b8520a5 Cython/Compiler/ModuleNode.py > --- a/Cython/Compiler/ModuleNode.py Wed Oct 15 21:48:31 2008 +0200 > +++ b/Cython/Compiler/ModuleNode.py Thu Oct 16 09:56:51 2008 +0200 > @@ -1734,7 +1734,7 @@ class ModuleNode(Nodes.Node, Nodes.Block > # variables to None. > for entry in env.var_entries: > if entry.visibility != 'extern': > - if entry.type.is_pyobject: > + if entry.type.is_pyobject and entry.used: > code.put_init_var_to_py_none(entry) > > def generate_c_function_export_code(self, env, code): > _______________________________________________ > 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
