Questions tagged [c-api]

154 questions
44
votes
4 answers

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

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…
rowman
  • 1,516
  • 1
  • 16
  • 26
15
votes
2 answers

SQLite: Sharing Connections across threads to read and write

I have an application that uses SQLite(version 3.7.2) to store data. I have a SQLite connection shared between multiple threads that writes and reads from the same SQLite db. SQLite is compiled with DSQLITE_THREADSAFE=1 which means SQLite is in…
omggs
  • 1,163
  • 1
  • 11
  • 23
10
votes
3 answers

Passing exceptions across a C API boundary

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…
Seth Carnegie
  • 73,875
  • 22
  • 181
  • 249
10
votes
2 answers

what dbus performance issue could prevent it from embedded system?

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…
minghua
  • 5,981
  • 6
  • 45
  • 71
8
votes
3 answers

"Hello TensorFlow!" using the C API

For learning purposes, how to code this Python example using the TensorFlow C API ? import tensorflow as tf hello = tf.constant("hello TensorFlow!") sess=tf.Session() print(sess.run(hello)) I have tried it this way: #include #include…
7
votes
0 answers

Optimizing Lua for embedded processor?

I am embedding Lua in a programm for no-eabi device with 16Mhz 32-bit ARM7TDMI processor and 256Kb RAM (yes, that's GBA). Currently it's working flawlessly (thank you, StackOveflow users, for answering my questions), doing easy tasks, but what…
6
votes
1 answer

How can we access PY_SSIZE_T_MAX value from python?

I'm in python code and need to check some value against PY_SSIZE_T_MAX (defined in the C-API of python). Can I access to PY_SSIZE_T_MAX value directly ? If not, is there a way to infer it thanks to python's behavior ? Or could I safely deduce it…
vaab
  • 9,685
  • 7
  • 55
  • 60
6
votes
1 answer

DBus synchronous call timeout

I have a DBus server which exposes a method that requires a huge time to complete (about 3 minutes). The client performs a synchronous call to this method. The problem is, after exactly 25 secs the client throws an error because 'did not receive a…
Cristiano
  • 856
  • 10
  • 24
5
votes
2 answers

How does import_array in numpy C API work?

I am trying to convert a c-style array in c++ to a numpy array and ran into problems when trying to use the "PyArray_SimpleNewFromData" function. It turns out I need to call import_array() Though I do not understand how to call this function.…
W. Verbeke
  • 355
  • 2
  • 12
4
votes
0 answers

Invalid GraphDef in Tensorflow 2.2.0 saved model while using TF_GraphImportGraphDef in c_api

I saved a keras model in tf 2.2.0 in Python via: model.save('model', save_format='tf') And it gives me a saved_model.pb in the "model" directory. I want to make inference via c_api, and the following code using the function:…
Weishuo
  • 41
  • 3
4
votes
0 answers

lua_resume(): What is the meaning of the second argument?

Note: There are some questions below that illustrate my thinking, but the only answer I'm looking for is the answer to the actual question, in the title. Not asking for "a book" here, or itemized responses to all of those. I'm trying to start a…
BadZen
  • 4,083
  • 2
  • 25
  • 48
4
votes
2 answers

Accessing the c pointer to structure in python

Is it possible to cast an int to a class type ? I have the following code in C: #include "Python.h" #define PYTHON_FILENAME "modelparam" void getmodelparam(long pModelParam) ; typedef struct { int seconds; int nanoseconds; } someTime; int…
Sagar Masuti
  • 1,271
  • 2
  • 11
  • 30
4
votes
1 answer

numpy C-API: scalar multiplication in C

How can I perform an element-wise multiplication of a numpy-nd-array with an arbitrary double-scalar in C? I'm searching for a api-function like this: // C-code PyArray_MultiplyWithScalar((PyArrayObject *) myarray, double…
Hensing
  • 421
  • 3
  • 6
3
votes
0 answers

Installing C API for Tensorflow on Macbook M1

I am trying to install C API of tensorflow on Macbook M1 to execute it in Go. I followed this guide by tensorflow developers but got stuck when running the hello_tf.c file with this command gcc hello_tf.c -ltensorflow -o hello_tf. This is hello_tf.c…
phuclhoang
  • 33
  • 3
3
votes
2 answers

How to prevent deletion of a raw pointer that is used as shared pointer?

I implemented a C-API for a C++ class which uses shared-pointers of other objects to access them. In my C-API I can of course only get raw pointers. So I "convert" the raw pointer in my C-API to a shared-pointer and use this then with my C++ class…
1
2 3
10 11