How can I use C++ class in Python?

后端 未结 3 1840
滥情空心
滥情空心 2020-12-23 09:26

I have implemented a class in C++. I want to use it with Python. Please suggest step by step method and elaborate each step. Somthing like this...



        
3条回答
  •  执念已碎
    2020-12-23 10:11

    Look into Boost.Python. It's a library to write python modules with C++.

    Also look into SWIG which can also handle modules for other scripting languages. I've used it in the past to write modules for my class and use them within python. Works great.

    You can do it manually by using the Python/C API, writing the interface yourself. It's pretty lowlevel, but you will gain a lot of additional knowledge of how Python works behind the scene (And you will need it when you use SWIG anyway).

提交回复
热议问题