[C++-sig] (Stefan Seefeld)(Nat Goodspeed) pass function pointer to Re: (Stefan Seefeld)(Nat Goodspeed) pass function pointer to c extension function in python
seefeld at sympatico.ca
Thu Oct 5 16:49:19 CEST 2006
Qinfeng(Javen) Shi wrote:
> Hi Stefan and Nat,
> 'process()' is implemented in c. It didn't lose much speed when I
> wrapped it into python. Speed is very important for it.
> The problem turns out to be:
> (1)I know how to wrap a function pointer op, but I don't know how to
> wrap it callable in python.
> (2)And I know how to wrap a normal function callalbe in python, but I
> don't know how to wrap a function which has a function pointer argument.
> I tried it in the same way with what I did for normal function, but failed.
If both the 'process' function as well as the functions it should optionally
call are provided by C++, why don't you just use some other parameter (a string,
say), and then assign to your C++ function pointers, based on that discriminator ?
I.e., you'd simply have some mapping from strings to function pointers, and then
let the python side only care about the strings ?
I think that's about what the other poster suggested initially...
More information about the Cplusplus-sig