python-c-api
Create an object using Python's C API
Say I have my object layout defined as: 开发者_运维百科typedef struct { PyObject_HEAD // Other stuff...[详细]
2023-01-24 12:43 分类:问答Returning a tuple of multipe objects in Python C API
I am writing a native function that will return multiple Python objects PyObject *V = PyList_New(0); PyObject *E = PyList_New(0);[详细]
2023-01-11 16:26 分类:问答Calling a python method from C/C++, and extracting its return value
I\'d like to call a custom function that is defined in a Python module from C. I have some preliminary code to do that, but it just prints the output to stdout.[详细]
2023-01-08 04:23 分类:问答Python C API: Switch on PyObject type
I have some code to interface Python to C++ which works fine but every time I look at it I think there must be a better way to do it.On the C++ side there is a \'variant\' type that can deal with a fi[详细]
2023-01-04 03:22 分类:问答Define a global in a Python module from a C API
I am deve开发者_开发技巧loping a module for Python using a C API. How can I create a variable that is seen as global from Python?[详细]
2023-01-02 14:27 分类:问答numpy array C api
I have a C++ function returning a std::vector and I want to use it in python, so I\'m using the C numpy api:[详细]
2023-01-01 12:34 分类:问答To convert PyBytesObject type to PyUnicodeObject type in python3
How to convert pyunicodeobject type to pybytesobject type? Example: function(PyBytesObject* byteobj){ ....operation..[详细]
2022-12-30 07:23 分类:问答Implementing PyMyType_Check methods with Python C API?
All the Python-provided types have a check method (i.e., PyList_Check) that allows you to check if an arbitrary PyObject* is actually a specific type.[详细]
2022-12-30 00:40 分类:问答Static Variables in Python C API
How would one expose \"static\" variables like t开发者_如何学Chis class MyClass: X = 1 Y = 2 via the C API? The only variable on the PyTypeObject that looks like it would work is tp_members, but I[详细]
2022-12-22 06:44 分类:问答How does one produce a specific unicode character with Python's C-API?
I\'m writing a Python extension that runs through a Py_UNICODE array, finds specific (ASCII, if it matters) characters, i.e. \'\\\' or \'\\n\', and does some additional stuff for each one that it find[详细]
2022-12-22 02:44 分类:问答