Dear list.
Sorry for the vague question, but probably someone has already done
this and I don't have to start from scratch ...
I have written a wrapper
(
https://github.com/spatialaudio/python-sounddevice) for a C library
(PortAudio) using CFFI with its in-line ABI mode. This works great and
I definitely want to keep maintaining that.
However, there is a certain use case, where using the API mode would
be preferable. Namely, the C library uses a callback function that is
called in a high-priority thread and for some specialized
applications, it is supposed to do some work in a fixed time frame of
a few milliseconds. Implementing this callback in Python is not
reliable enough because of garbage collection and the GIL which is
shared between the high-priority thread and the rest of the Python
program.
I think it would make sense to implement the callback in C in this
case and provide the code in ffibuilder.set_source(). This way, the
callback could run in native C speed and without using the GIL.
Now my questions:
Can I have both within the same codebase?
Has anybody already tried a similar thing?
Is this a bad idea?
cheers,
Matthias