Lisandro Dalcin wrote:
> Error converting Pyrex file to C:
> ------------------------------------------------------------
> ...
> cdef int f1():
>    cdef int i = 0
>    with gil:
>   ^
> ------------------------------------------------------------

I started to add this to Pyrex, but half way through
I realised it was going to be much more complicated to
implement than I had thought, and backed out of the idea
in favour of having a 'with gil' clause on the whole
function instead, e.g.

   def myfunc() with gil:
     ...

> Of course, this one-line patch would enable it.
> 
> -    if s.sy == 'IDENT' and s.systring == 'nogil':
> +    if s.sy == 'IDENT' and s.systring in ('gil', 'nogil'):
> 
> BTW, If the above is enabled, the following patch would be needed
> 
>      def generate_execution_code(self, code):
>          if self.state == 'gil':
> -            code.putln("PyGILState_Release();")
> +            code.putln("PyGILState_Release(_save);")

You'd have to do quite a lot more than that. I don't
remember all the details, but essentially if you want to
use Python stuff anywhere in the function, there's setup
code that needs to run with the GIL held before you even
get into the user's code. It's not easy to just turn it
on half way through.

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

Reply via email to