2010/12/11 Stefan Behnel <stefan...@behnel.de>: > Vitja Makarov, 10.12.2010 09:22: >> 2010/12/10 Stefan Behnel: >>> Stefan Behnel, 09.12.2010 10:46: >>>> Vitja Makarov, 08.12.2010 22:45: >>>>> Please review this patch. It's not yet finished, and mostly doesn't work. >>>>> But you can take a look at patch and generated code. >>>> >>>> I'll take a close look ASAP. >>>> >>>>> - Temps are saved/restored/allocated inside YieldExprNode using >>>>> helper ClosureTempAllocator >>> >>> Ok, that currently lives in ParseTreeTransforms, which is totally the wrong >>> place for anything that generates code. It also mixes functionality that >>> normally lives in Symtab.py with functionality that lives in Code.py. >>> >> >> Yes, I know. That was placed there to give it a try (actually I'm not >> sure what is the best place for it). ClosureTempAllocator now is >> attribute of defnode and all yieldnodes, that's not clean. > > FunctionState in Code.py seems like a good place to hold a reference, at > least for the code generation part of it. >
At some point we can call code.set_closure_class() that would create code.temp_allocator and then refer to it as code.temp_allocator. temp_allocator isn't good name here maybe closure_temps? > >> ExprNode.StopIterationNode isn't expression should it be moved to Nodes.py? > > Why not drop it completely and generate the code in the function node > instead? ISTM that the only reason it's there is to drop one line of code > at the end of the function body. That can be done much easier. > > Sure. You've already done this, thanks! >> create_abstract_generator() is rather dirty > > I've seen worse. ;) > > >> I don't know how to bind C functions to CClass. > > Such as? > > e = declare() e.func_cname = ... e.signature = ... I think that there should be a short way >> I think that generator body could have PyObject *body(PyObject *self, >> PyObject *value) signature >> With value=Null meaning exception. > > See the CEP. ;) > Yeah! Forget about that, that's already done. I was looking into python implementation and it has `i_exc` arg. > >>>>> - PyxGenerator methods are defined via declare_var >>>> >>>> Should we call that "CyGenerator" ? :) >>> >>> I actually meant to call it "CyGenerator" at the Python level, but I now >>> see that it's actually a purely internal thing. That makes __Pyx_Generator >>> a better choice, given that "__pyx_" is the globally reserved prefix in >>> Cython code. >> >> Should rename it back ;) > > Yep. > __pyx_CyGenerator_(Send|Close)() <-- or lover case suffix is better, should look at pep7? class __pyx_CyGenerator type __pyx_CyGeneratorType is that ok? > >> How can I declare function entry with METH_VARGS signature? >> Using TypeSlots I can add METH_VARGS|METH_KWARGS entries but not >> single METH_VARGS >> >> That's preferd for "throw" method. > > I see what you mean. It's a minor issue, though. Just ignore it for now, or > raise an exception if kwargs are passed in. After all, .throw() is rarely > used and not performance critical at all. > ok >> Pyregr tests works now on hudson but there is still problem with heapq >> don't understand is that related to generators or not > > Not sure either. It works for me in Py3 but not in Py2.7. I see you've fixed this issue. Cool. > disable generators test in Py2.4 - depends on GeneratorExit and potentially > other stuff May be it's better to generate another exception (StopIteration) in 2.4 and control this with #ifdefs ... #endif What do you think about generate_preamble? Think it's not correct name. In GeneratorWrapper() buffer cleanup code isn't implemented when closure is created. What is the place for YieldCollector? About genexp: now it should be easy to implement just like lambda function -- vitja. _______________________________________________ Cython-dev mailing list Cython-dev@codespeak.net http://codespeak.net/mailman/listinfo/cython-dev