c-api

Segmentation fault in PyArray_SimpleNewFromData

房东的猫 提交于 2019-12-01 09:06:46
I am looking to pass an array from C++ to Python using C-API. By looking at various topics here, I came to know that I should be using PyArray_SimpleNewFromData method. When I am trying to implement on a very small array, I am getiing a segmentation fault in my code which I am not able to detect. Can anyone help me with this issue? C++ code : void init_numpy() { import_array(); } int main(int argc, char *argv[]) { PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *pArgs, *pXVec, *xarr1; PyObject *c ; PyObject *pValue1 ; int fArray[2] = {10,1} ; PyObject *p = NULL ; npy_intp m1 = 2; Py

what dbus performance issue could prevent it from embedded system?

﹥>﹥吖頭↗ 提交于 2019-11-30 20:04:48
From my reading dbus performance should be twice slower than other messaging ipc mechanisms due to existence of a daemon. In the discussion of the so question which Linux IPC technique to use someones mention performance issues. Do you see performance issues other than the twice slower factor? Do you see the issue that prevent dbus from being used in embedded system? To my understanding if dbus is intended for small messages. If large amount of data need to be passed around, one of the solution is to put the data into shared memory or a pile, and then use dbus to notify. Other ipc mechanisms

Passing exceptions across a C API boundary

半城伤御伤魂 提交于 2019-11-30 13:04:20
I am writing a library in C++ which uses an older C API. The client of my library can specify callback functions, which are indirectly called through my library which is called through the C API. This means that all exceptions in the client callbacks must be handled. My question is this: how can I catch the exception on one side of the boundary and re-throw it once the C API boundary has been recrossed and the execution is back in C++ land so that the exception can be handled by client code? With C++11 we could use: std::exception_ptr active_exception; try { // call code which may throw

Passing exceptions across a C API boundary

别来无恙 提交于 2019-11-29 18:38:25
问题 I am writing a library in C++ which uses an older C API. The client of my library can specify callback functions, which are indirectly called through my library which is called through the C API. This means that all exceptions in the client callbacks must be handled. My question is this: how can I catch the exception on one side of the boundary and re-throw it once the C API boundary has been recrossed and the execution is back in C++ land so that the exception can be handled by client code?

Sending a C++ array to Python and back (Extending C++ with Numpy)

六眼飞鱼酱① 提交于 2019-11-28 16:43:05
I am going to send a c++ array to a python function as numpy array and get back another numpy array . After consulting with numpy documentation and some other threads and tweaking the code, finally the code is working but I would like to know if this code is written optimally considering the: Unnecessary copying of the array between c++ and numpy (python) . Correct dereferencing of the variables. Easy straight-forward approach. C++ code: // python_embed.cpp : Defines the entry point for the console application. // #include "stdafx.h" #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include

Sending a C++ array to Python and back (Extending C++ with Numpy)

徘徊边缘 提交于 2019-11-27 05:17:29
问题 I am going to send a c++ array to a python function as numpy array and get back another numpy array . After consulting with numpy documentation and some other threads and tweaking the code, finally the code is working but I would like to know if this code is written optimally considering the: Unnecessary copying of the array between c++ and numpy (python) . Correct dereferencing of the variables. Easy straight-forward approach. C++ code: // python_embed.cpp : Defines the entry point for the