Are there advantages to use the Python/C interface instead of Cython?

前端 未结 3 1564
隐瞒了意图╮
隐瞒了意图╮ 2020-12-24 01:16

I want to extend python and numpy by writing some modules in C or C++, using BLAS and LAPACK. I also want to be able to distribute the code as standalone C/C++ libraries. I

3条回答
  •  佛祖请我去吃肉
    2020-12-24 01:43

    The main disadvantage of the Python/C API is that it can be very slow if it's used in an inner loop. I'm seeing that calling a Python function takes a 80-160x hit over calling an equivalent C++ function.

    If that doesn't bother your code then you benefit from being able to write some chunks of code in Python, have access to Python libraries, support callbacks written directly in Python. That also means that you can make some changes without recompiling, making prototyping easier.

提交回复
热议问题