Re: [Cython] nested prange
Ok, great. Indeed, there is a bug in gcc 4.5, which is fixed I believe in 4.6. For the OpenMP backend that's not such a big issue, as it's likely not very useful anyway. On 26 November 2011 18:35, Robert Bradshaw wrote: > I'm all for allowing it at the Cython level even though we can't emit > code for it at the C level (due to C compiler bugs, right?) > > - Robert > > On Fri, Nov 25, 2011 at 3:12 AM, mark florisson > wrote: >> I think we should allow nested prange()s, although it won't invoke >> nested OpenMP parallelism now, it still specifies that iterations are >> independent which can be useful for optimizations now (e.g. collapsing >> two loops into one) and in the future with other backends. Any >> thoughts or objections? >> ___ >> cython-devel mailing list >> cython-devel@python.org >> http://mail.python.org/mailman/listinfo/cython-devel >> > ___ > cython-devel mailing list > cython-devel@python.org > http://mail.python.org/mailman/listinfo/cython-devel > ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
[Cython] Correct way of defining enums
Hi all, What is currently the correct way of defining an enum? I am trying to call a NumPy function with an enum as its third argument, and the following does not compile: cimport numpy as np np.import_array() cdef enum NPY_SEARCHSIDE: NPY_SEARCHLEFT = 0 NPY_SEARCHRIGHT = 1 cdef sort_something(): cdef np.ndarray[double, ndim=1] sample_prob = np.empty(5, np.float64) cdef np.ndarray[double, ndim=1] cum_prob = np.empty(5, np.float64) cdef NPY_SEARCHSIDE side = NPY_SEARCHRIGHT results = np.PyArray_SearchSorted(cum_prob, sample_prob, side) It fails with: enum.c:1081:3: error: incompatible type for argument 3 of ‘(struct PyObject * (*)(struct PyArrayObject *, struct PyObject *, enum NPY_SEARCHSIDE))*(PyArray_API + 1048u)’ enum.c:1081:3: note: expected ‘NPY_SEARCHSIDE’ but argument is of type ‘struct PyObject *’ I tried different ways of defining the enum, e.g. cdef extern from "ndarraytypes.h": cpdef enum NPY_SEARCHSIDE: NPY_SEARCHLEFT = 0 NPY_SEARCHRIGHT = 1 But that doesn't work either. Any suggestions would be appreciated. Regards Stéfan ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel