[Cython] 'Referenced before assignment' warning triggered due to OpenMP directives?

2013-11-29 Thread Yury V. Zaytsev
Hi,

I'm trying to find out whether the number of threads has been actually
set to what I wanted it to be, but the compiler tells me that I'm trying
to reference a variable before assignment. This doesn't happen when I
simply release the GIL, but only within a parallel section.

Is it a problem with Cython or I'm missing something obvious?

Thanks!

$ cat ompt.pyx 
cimport openmp
from cython.parallel import parallel, prange

cdef Py_ssize_t x = 1

with nogil, parallel():
x = openmp.omp_get_num_threads()

print("Number of OpenMP threads is '{}'!".format(x))

$ cython ompt.pyx 

Error compiling Cython file:

...
cdef Py_ssize_t x = 1

with nogil, parallel():
x = openmp.omp_get_num_threads()

print("Number of OpenMP threads is '{}'!".format(x))
 ^


ompt.pyx:9:50: local variable 'x' referenced before assignment


-- 
Sincerely yours,
Yury V. Zaytsev


___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


[Cython] "embedsignature" and "autotestdict" features in Py3.4

2013-11-29 Thread Stefan Behnel
Hi,

recent changes in Py3.4 affect the functionality of the two directives
"embedsignature" and "autotestdict".

The so-called "argument clinic" extracts any embedded signatures from
docstrings and moves them into a new property "__text_signature__". This is
done at runtime, i.e. when either "__doc__" or "__text_signature__" are
requested.

http://hg.python.org/cpython/file/6a3e09cd96f3/Objects/methodobject.c#l182

I personally consider this a feature (and it works nicely with the
signatures that Cython embeds), but you may or may not agree. It broke some
of our own doctests, at least, because the "__doc__" value that we tested
for was no longer the same.

Regarding the "autotestdict", CPython also got smarter and now finds
doctests embedded in C implemented functions all by itself. This is clearly
an improvement compared to the previous behaviour. However, this also means
that it now executes both the doctest of the function itself and its copy
in the generated "__test__" dict (stored in the module under that name),
meaning that it executes all function doctests twice. This also broke some
of Cython's own doctests for us, which modified global state and thus
failed the second time.

I'm yet unsure if we should try to do something about this. Currently, the
explicit doctest dict is generated by default, so all code that uses
doctests in function docstrings suffers from this. We might be able to make
Cython a bit smarter so that these docstrings are left out of the test dict
when (C-)compiling in CPython 3.4. Deciding which ones are still needed
might be a bit tricky, though...

Stefan
___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel