[Cython] OpenMP support

Stefan Behnel stefan_ml at behnel.de
Tue Mar 8 18:50:15 CET 2011

mark florisson, 08.03.2011 18:00:
> What I meant was that the
> wrapper returned by the decorator would have to call the closure for
> every iteration, which introduces function call overhead.
> I guess we just have to establish what we want to do: do we
> want to support code with Python objects (and exceptions etc), or just
> C code written in Cython?

I like the approach that Sturla mentioned: using closures to implement 
worker threads. I think that's very pythonic. You could do something like 
this, for example:

     def worker():
         for item in queue:
             with nogil:

     start_threads(worker, count)

Note that the queue is only needed to tell the thread what to work on. A 
lot of things can be shared over the closure. So the queue may not even be 
required in many cases.


More information about the cython-devel mailing list