Hi, I have recently uncovered some mysterious behaviour and Dag Sverre suggested on the cython-users list that I file a bug report. Since I don't have an account, I'm sending this to the dev list in the hope that this is a simple bug that can be fixed easily.
I've been trying to go through the cython numpy tutorial (http:// wiki.cython.org/tutorials/numpy) and reproduce the speed-ups with pure python mode (http://wiki.cython.org/pure), either with or without an accompanying .pxd file. The sticking point for me is specifying the dimensions of the numpy array args. I can't find any way to do it without breaking python compatibility in the .py file. Oddly, a cython.locals decorator in a .pxd file should work, but it has no effect whatsoever on the generated .c file. For example, with a class defined to set ndim (without using a comma inside brackets in the .pxd, which will fail to compile): cdef class MyArray: cdef __cythonbufferdefaults__ = {"ndim": 2, "mode": "strided"} A non-python def line in .py works fine. def naive_convolve(MyArray[DTYPE_t] f, MyArray[DTYPE_t] g): But setting the type with cython.locals in a .pxd, like this, @cython.locals(f=MyArray[DTYPE_t],g=MyArray[DTYPE_t]) cpdef naive_convolve(f, g) produces a .c file that is identical to not using the decorator at all. #[email protected](f=MyArray[DTYPE_t],g=MyArray[DTYPE_t]) cpdef naive_convolve(f, g) Any idea why cython.locals has no effect? Every other way I can think of to set ndim in pure python mode fails to compile. I've tried this with cython 0.12, with both python 2.5 and 2.6 (enthought epd-6.0.1- rh5-x86). I really want to preserve python compatibility, but setting ndim makes the biggest performance improvement. Thanks for any help. Trevor _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
