On 12/03/2010 01:56 PM, Sturla Molden wrote: >> On 12/2/10 3:08 AM, Dag Sverre Seljebotn wrote: >> > >> I expect that being able to inline a generator would be quite a trick. >>
(That was actually said by Robert Kern.) > Except that applying a function along an axis is the kind of thing onw > might want to workshare/multithread in a "nogil" block. Using a Python > object like an iterator here kind of takes that advantage away, i.e. one > has to hold the GIL to access the iterator. In additon to make C level > threads compete for the GIL, it also prevents OpenMP's scheduler from > balancing the work load. That is why I rather collect a temporary array of > pointers instead. > There's no actual Python iterator involved here...As Robert Kern said, it's basically just a proposal for loop-macros that will be convenient to use for people used to the yield keyword. Still, one must release the gil somewhere. I.e. there must be a "with nogil" clause within the generator. Hmm, perhaps a bit confusing...perhaps we'd require a "with nogil" in the for-loop body as well in that case. It clearly needs more thought, but I don't think it is fundamentally broken, and as (AFAIK) nobody stands ready to implement it right now I don't think there's much point to discuss this further... Dag Sverre _______________________________________________ Cython-dev mailing list Cython-dev@codespeak.net http://codespeak.net/mailman/listinfo/cython-dev