how to deal with the PyObject* from C++ in Python

前端 未结 3 730
粉色の甜心
粉色の甜心 2021-01-03 09:06

I create DLL wrote in C++ , the exporting function returns PyObject * .Then I use ctypes to import the DLL in Python . Now , how can I get the real PyObject ??

here

3条回答
  •  一个人的身影
    2021-01-03 09:46

    I'm not exactly clear what you are asking. But I suppose you mean to ask what you can do now with your DLL.

    1. Well, in order to use it appropriately, you'll have to build a special DLL which directly can be imported as a module in Python. In order to determine what to do in order to use this, it is best you have a look for other modules, how they do it. E. g. MySQLdb could be a candidate.

      In short, you have this "wrapper" DLL call your function.

    2. But if I have a second look at your question now, I see that you are trying to load your DLL via ctypes. This is viable as well, maybe even better, and you'll have to use the ctypes.py_object data type.

提交回复
热议问题