Hi there,
thanks for the great work on Cython! It has already helped me to a significant
speedup on my code.
Working to port parts of my numpy-based program to Cython, I stumbled over a
number of bugs/shortcomings in the implementation of buffer types and the
numpy-cython interface that I would like to report in the following. For every
snippet, assume a header of
--------
import numpy
cimport numpy
--------
==============
1. (reported before) extension types cannot have buffer types as elements. The
snippet
--------
cdef class myclass:
cdef numpy.ndarray[numpy.float_t] data
--------
gives the cython-compiler error "Buffer types only allowed as function local
variables". I can work around this by keeping a pointer to the data as an
additional member, but that results in a tremendous uglification of the whole
code...
==============
2. C functions cannot have buffer types as arguments. The snippet
--------
cdef myfunc(numpy.ndarray[numpy.float] arg):
pass
--------
produces the cython *syntax error*
cdef myfunc(numpy.ndarray[numpy.float] arg):
^
------------------------------------------------------------
/home/nobbi/NNlab/src/cython-bugs/tryout2.pyx:6:39: Expected ')'
The same thing works fine with def instead of cdef.
==============
3. On typed variable of type numpy.ndarray, the .shape member does not work
---------
cdef numpy.ndarray var = numpy.zeros((3,))
print var.shape
---------
gives the cython compiler error "Cannot convert 'numpy.npy_intp *' to Python
object"
==============
4. The numpy.float_t type is not handled correctly. The snippet
------------
cdef class myclass:
cdef readonly:
double var_d
numpy.float_t var_nf
def __init__(self):
self.var_d = 42.0
self.var_nf = 42.0
c = myclass()
print "double (correctly given as 42.0):",c.var_d
print "numpy.float_t (should be 42.0):",c.var_nf
------------
compiles fine, but prints
double (correctly given as 42.0): 42.0
numpy.float_t (should be 42.0): 0.0
so the value of var_nf seems to be lost somewhere on the way.
===============
I am not sure which of these are simply bugs, which are missing features and
which might be misunderstandings on my side.
Thanks for any help on this!
Greetings,
Norbert
--
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss
für nur 17,95 Euro/mtl.!*
http://dslspecial.gmx.de/freedsl-surfflat/?ac=OM.AD.PD003K11308T4569a
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev