On 04/05/2011 11:01 AM, Stefan Behnel wrote:
mark florisson, 05.04.2011 10:44:
On 5 April 2011 10:34, Stefan Behnel wrote:
mark florisson, 05.04.2011 10:26:
On 5 April 2011 09:21, Dag Sverre Seljebotn wrote:
Justification for Cython-specific syntax: This is something that is
really
only useful if you can release the GIL *outside* of the loop. So I
feel
this
is an area where a custom Cython solution is natural, sort of like
"cdef
extern", and the buffer access.
Since a similar pure-Python solution is rather useless, I also think
there's
less incentive for making something that works well in pure-Python
mode.
Which feature is Cython specific here? The 'with a, b as c:' thing?
No, the syntax is just Python. It's the scoping that's Cython specific,
including the local variable declarations inside of the "with" block.
Hmm, but you can use cython.declare() for that, no?
cython.declare() is a no-op (or just a plain assignment) in Python.
But the thread-local scoping of these variables cannot be emulated in
Python. So this would be a feature that cannot be used in pure Python
mode, unlike closures.
The intention of prange was certainly to fall back to a normal
single-threaded range in Python mode.
Because of the GIL there would rarely be any benefit in running the loop
in parallel -- only if you immediately dispatch to a long-running task
that itself releases the GIL, but in those cases you should rather stick
to pure Python in the first place and not bother with prange.
I think the chance of seeing real-life code that both requires prange to
run optimally in Cython, and that would not be made slower by more than
one thread in Python, is pretty close to zero.
Dag Sverre
_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel