[Pyrex] External functions and extension types: Was: Please
support C++
Greg Ewing
greg.ewing at canterbury.ac.nz
Thu Oct 27 04:13:55 CEST 2005
Lenard Lindstrom wrote:
> I was wondering if any decision has been made as to how external
> functions returning extension types will be handled.
No firm decision yet, but I'm thinking about a scheme
which will track both the logical type and the actual
declared C type of all expressions. This would open
up flexibility for future policy decisions on such
things as whether all temporary variables are declared
as PyObject * or not, and a possible "split" type
declaration syntax for handling the above problem.
> What is not handled is the case where a function is logically defined
> to return 'object' but in fact returns something else in the .h file.
I don't see what you would gain by declaring it that
way, rather than making the Pyrex declaration match
the actual declaration.
> The plan is to always C cast the return value of an external
> function returning a Python object but not functions defined in
> Pyrex.
That may serve as an interim solution, but I wouldn't
like it to be made permanent. Ultimately I'd like a
scheme in which Pyrex always knows exactly how everything
is declared and acts accordingly.
> If a special declaration is to be used then may I suggest something
> like this:
>
> cdef extern from "something.h":
> cdef class EXTTYPE ...
> cdef <EXTTYPE> somefunc(...)
I'm currently thinking of something like
cdef <object> MyType somefunc(...)
so you get to be explicit about both the logical and
actual type. Have to think more about how to weave this
into C's inside-out type declaration syntax, though.
> But I do not wish to explore this any further until
> a decision is made.
You're not likely to get any definitive decisions about
this until I actually release the next version, since
I won't really know whether what I'm thinking of is
workable until I've tried to implement it.
I probably won't be using any of your patches as-is
anyway. Not that I don't appreciate your efforts, but
I feel I need to keep a firm grip on the overall design,
or it will all turn to custard...
--
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg.ewing at canterbury.ac.nz +--------------------------------------+
More information about the Pyrex
mailing list