[Cython] Callback functions for C lib in Python

Mohamed Lrhazi lrhazi at gmail.com
Sun Apr 26 08:21:01 CEST 2009


Thanks Robert.

In the example, the external C function is declared like this:

void find_cheeses(cheesefunc user_func, void *user_data)

and user_data is used to pass the pointer, to the Python function, to
the lib, and the lib sends it back to the callback.

What if the external lib function expects just one value, and that is
the pointer to a callback?

Thanks a lot,
Mohamed.


On Sat, Apr 25, 2009 at 10:02 PM, Robert Bradshaw
<robertwb at math.washington.edu> wrote:
> On Apr 25, 2009, at 6:25 PM, Mohamed Lrhazi wrote:
>
>> Hello,
>>
>> I am trying to write an extension module, to make a C library
>> available for use by the Python user.
>>
>> The lib needs to be passed pointers to callback functions. how do I
>> code this in Cython, so the actual functions are provided by the
>> Python code?
>>
>> Any code examples I could look at for inspiration?
>
> Yes, there's an example of callbacks in the Demos folder of Cython.
>
> - Robert
>
>
> _______________________________________________
> Cython-dev mailing list
> Cython-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/cython-dev
>



-- 
" Logic merely sanctions the conquests of the intuition."
Jacques Hadamard


More information about the Cython-dev mailing list