[Pyrex] ctypedef problem and improvement
Greg Ewing
greg at cosc.canterbury.ac.nz
Mon May 24 02:37:55 CEST 2004
Serge Barbosa Da Torre <sergiobdt at yahoo.com>:
> Often we are defining some functions which do not = take any
> parameters, or in case of methods do not use the self parameter = at
> all. In these cases, I think it should be easy to suppress the call =
> to PyArg_ParseTupleAndKeywords in the resulting C code.
It would, although I'd still want to put in a check that
no parameters were passed, and it's not clear whether this
would be significantly less expensive than a PyArg_ParseTuple
call with an empty format string. I'll look into this.
> Then what we typically want to do in the pyx file is:
>
> cdef from "module.h":
> ctypedef struct MyStruct
>
> cdef class MyClass:
> cdef MyStruct thisstruct
>
> However this is currently not possible: the pyrexc compiler fails the =
> compilation with a "variable type MyStruct is incomplete"
You can lie to it:
cdef extern from "module.h":
ctypedef struct MyStruct:
pass
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg at cosc.canterbury.ac.nz +--------------------------------------+
More information about the Pyrex
mailing list