[Cython] Callback functions for C lib in Python

Stefan Behnel stefan_ml at behnel.de
Sun Apr 26 08:29:30 CEST 2009


Hi,

please don't top-post.

Mohamed Lrhazi wrote:
> 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?

In that case, pass the pointer to the callback.

I imagine that your question implies: "how do I pass some state into the
callback function?". That depends on the library you are using, maybe it
passes something into the callback function that you can control from your
outside code.

Stefan


More information about the Cython-dev mailing list