开发者

What is the exact requirement for defining a python tp_call function?

I am binding C++ classes to Python and have come to an interesting solution to a previous problem, unfortunately this has lead to another question that there seems to be no easy answer too.

I am wrapping each function into a "callable" PyObject, what makes it callable is having the call function define (C side this is the tp_call method in the PyTypeObject).

The tp_call seems to take a ternary function which just accepts (PyObject*, PyObject*, PyObject*) as its argument list.

Now the problem is that I need for this function to just take the place of the PyCFunction, which just takes the开发者_开发知识库 arguments (PyObject* self, PyObject* args). Now python side this can be done easily, but C side it seems to need the ternary function when I just want a binary one, so is there anyway to make the callable function simple take the PyCFunction pointer or a way to encapsulate it as such?


The third PyObject* is the kwargs. Write a wrapper that just... doesn't pass them. Raising TypeError if it contains anything is optional.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜