[Pyrex] newby guidance

Robin Becker robin at reportlab.com
Thu Jun 26 10:14:18 CEST 2003


In article <200306260207.h5Q27GZ06132 at oma.cosc.canterbury.ac.nz>, Greg
Ewing <greg at cosc.canterbury.ac.nz> writes
>Robin Becker <robin at reportlab.com>:
.....
>But if Pyrex code needs to access any of its members, you
>will need to provide Pyrex declarations for at least
>those members.
..... I'm probably missing something here.

after

cdef extern from "myheader.h":
    struct MyStruct

Can we declare members sparsely, or do I have to repeat the whole thing
to get the layout the same? If the latter it seems likely to cause
errors.

How do I incorporate the layout of MyStruct into something I can add
methods to? I see one can do things like 

cdef class AStruct:
    cdef int width, height
    def __init__(self, w, h):
        self.width = w
        self.height = h 

so can I do

cdef class AStruct:
    cdef extern from "myheader.h":
        struct MyStruct

or even better

cdef extern class MyStruct from "myheader.h"
        def __new__(self):
                ......


More information about the Pyrex mailing list