On Nov 13, 2009, at 3:05 AM, Stefan Behnel wrote:

> Hi Robert,
>
> thanks for the feedback, I'll use it to write up a CEP for this.

Great.

> It looks like there's still room for discussion, and this isn't a  
> trivial/obvious
> thing to implement, so it's worth some planning.

Yeah. But like you said, it's not too far off either.

>> I assume the motivation is that this would be easier than just
>> generating a class with these methods every time? There's overhead to
>> calling virtual methods, and it seems odd to direct throw() and
>> __next__/send() into the same method, only to have an if statement to
>> separate them in its body.
>
> No, the if statement must be generated for each yield, so that the
> exception originates from the correct source line and takes the  
> correct
> exception handling path. Nothing keeps you from putting a yield into a
> try-except or try-finally block, for example. So there needs to be  
> some
> support in the yield node, which basically raises the exception. I  
> just set
> the exception values outside of the generator function to avoid  
> having to
> pass them into the function as arguments.

Oh, yes, you're right here. I wasn't fully thinking through the  
semantics of the throws method.

> True. In that case, we'd also have to know which temps were actually  
> used
> at some point. Maybe the yield node could automatically emit  
> corresponding
> cleanup code into a separate code writer that builds the __dealloc__  
> method.

If our temps a flat struct instead of a union of structs (and I don't  
think that'd be too wasteful as temps get freed and re-used), we  
should be safe just XDecrefing them whole set of them, just like the  
error exit cleanup in a normal function.

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to