bastibe / SoundCard

A Pure-Python Real-Time Audio Library
https://soundcard.readthedocs.io
BSD 3-Clause "New" or "Revised" License
689 stars 70 forks source link

CFFI's ABI vs API level #14

Closed mpariente closed 6 years ago

mpariente commented 6 years ago

I'm new to CFFI so this might be a simple question. I quote from CFFI's docs :

The ABI mode accesses libraries at the binary level, whereas the faster API mode accesses them with a C compiler.

If using a C compiler to install your module is an option, it is highly recommended to use the API mode described in the next paragraph. (It is also faster.)

If I'm not mistaken, what is used in soundcard is the in-line ABI, what are the reasons for this choice, knowing that the out-of-line API is supposed to be faster? Thanks

bastibe commented 6 years ago

Mostly that the API mode needs a compiler, and different wheels for different platforms.

I have not done my research, though, and don't actually know how much faster/slower the ABI/API modes actually are. However, it seems to me that the CFFI overhead is not significant in SoundCard, and can therefore be ignored. If this is true, it doesn't seem worthwhile to force all users to install a C compiler, and complicate the build process, just to save some non-critical performance.

That said, load times can certainly be improved with the technique described here: https://github.com/bastibe/SoundFile/commit/0eb546eefd7764b85aba59c87c075aeee24fa71e

mpariente commented 6 years ago

Noted, thanks !

I looked for benchmarks but didn't find any comparing API and ABI modes. I'll tell you if I find some.