Extending python - to swig, not to swig or Cython

后端 未结 10 735
栀梦
栀梦 2020-11-30 18:32

I found the bottleneck in my python code, played around with psycho etc. Then decided to write a c/c++ extension for performance.

With the help of swig you almost do

10条回答
  •  执笔经年
    2020-11-30 19:11

    If its not a big extension, boost::python might also be an option, it executes faster than swig, because you control what's happening, but it'll take longer to dev.

    Anyways swig's overhead is acceptable if the amount of work within a single call is large enough. For example if you issue is that you have some medium sized logic block you want to move to C/C++, but that block is called within a tight-loop, frequently, you might have to avoid swig, but I can't really think of any real-world examples except for scripted graphics shaders.

提交回复
热议问题