【发布时间】:2018-12-05 13:09:24
【问题描述】:
我目前在尝试检索我的 python 代码返回的值时遇到问题。
我的代码草稿是:
# I call a function that returns a PyObject
PyObject* pyObj_val = call_binding(...);
# This PyObject seems to be a PyInt as PyInt_Check returns 1
assert(PyInt_Check(pyObj_val) == 1);
# Now the only way i found to convert this PyInt to a [C] int is:
int my_val = (int) PyInt_AsLong(pyObj_val);
我想有一种方法可以在不经过长时间转换和 int 转换的情况下执行此操作。有人知道吗?
感谢您考虑我的请求。
【问题讨论】:
标签: python c python-c-api