Anatoly A. Kazantsev wrote: > cpdef python_foo(python_callback): > cdef c_callback(): > python_callback() > > c_foo(c_callback) > > where c_foo and c_callback from some C lib. > > I know in cython function nesting is not implemented. But if it was, is it > possible > to wrap callbacks this way?
No, this would not be possible, at least not without some very platform-dependent hackery[1]. The callback needs to be a plain C function, and there is no such thing as a closure in plain C. Cython might support nested C functions one day, but if they behave like closures, they won't be acceptable to something expecting a standard C function pointer. Footnotes: [1] It could be done if you're willing to dynamically generate machine code for a new function each time you want a new instance of the callback, but that would hardly be portable. -- Greg _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
