[Cython] Buffer must know exact C types
Stefan Behnel
stefan_ml at behnel.de
Sat Jul 5 07:11:34 CEST 2008
Hi,
Dag Sverre Seljebotn wrote:
> Currently, wherever a C type is used in Cython, it is enough to specify
> sort-of what kind of class of type it is... the following will work all
> right:
>
> cdef extern ...:
> ctypedef int int8
> ctypedef int int16
> ctypedef int int32
> ctypedef int int64
>
>
> However, when types are used in buffers:
>
> cdef object[int16, 3] x
>
> one must translate the type (dtype) into a character representation (as
> listed in http://docs.python.org/lib/module-struct.html).
What about going the opposite way and either a) replacing the type definition
in buffers by the type character entirely (not sure, but this might not work
if you require a specific type name to appear in the C code), or b) by
requiring users to provide both the type and the character in a suitable
buffer declaration syntax?
Stefan
More information about the Cython-dev
mailing list