[Pyrex] Passing struct between C function

Nicolas Pernetty nicopernetty at yahoo.fr
Sat Nov 5 15:21:58 CET 2005


Hello,

I would like to use some C functions within Python by using Pyrex but I
don't know how to overcome one major difficulty.

I have 2 C-functions foo_A and foo_B.

foo_A read some conf/data files and put all data in one major and
overcomplicated structure (which contain other structures and so on)

foo_B get this famous structure and other parameters to compute some
outputs.

Basically you only have to call foo_A once (to initialize the
structure) and after you can call foo_B as many times you want.

Now I don't know how to make pyrex wrappers to use foo_A and foo_B
because of the structure.

One solution I'm think about is to malloc'ed some area in memory to
contain the structure and only send to foo_B the pointer to this memory
(and after use a cast to convert) but I also don't know how to use
pointer with Pyrex (I mean passing one pointer to one Pyrex function to
another).

Does someone has made something like this ? If yes I would really like
an example...

Thanks in advance,



More information about the Pyrex mailing list