Efficient data flow between orthogonal C extensions?

Thomas Heller theller at python.net
Fri Jun 6 08:35:05 CEST 2003


mlh at furu.idi.ntnu.no (Magnus Lie Hetland) writes:

> In article <slrnbdvdlb.dfi.mlh at furu.idi.ntnu.no>, Magnus Lie Hetland wrote:
> >In article <87znkwwmbg.fsf at smtp.gsi.de>, Pierre Schnizer wrote:
> >[snip]
> >>Perhaps I should have been more explicit. If I get your viewpoint correctly, I
> >>can answer: SWIG generally can do the job you described above. 
> 
> I have now written a small test, but can't make this work. (For one
> thing, it seems that SWIG has started to create .py-wrappers for the c
> modules, and that I have to give a _foo name rather than a foo name to
> distutils etc. Hm. Oh, well.)
> 
> I've written the function
> 
>   void callback(char *);
> 
> in one module and the function
> 
>   void caller(void (*callback)(char *));
> 
> in another. When I swig/compile these, import them, and try to pass
> callback as a parameter to caller, I get the following error:
> 
>   TypeError: Type error. Expected _p_f_p_char__void
> 
> What am I doing wrong?

I have no answer to this question, and haven't really followed the
thread, but I have the vague impression that ctypes could also help
here. It allows to create C callable callback functions from Python
callable objects, see the qsort example in the tutorial.

Thomas




More information about the Python-list mailing list