Questions tagged [c-api]

154 questions
2
votes
2 answers

Cannot connect to postgreSQL server using libpq

I'm a complete novice trying to learn PostgreSQL. I'm trying to connect to my postgres server throught a C program using libpq. Here is the server status: home/planb/postgresql-9.2.4/Project status -o "-p 5555" pg_ctl: server is running (PID:…
kensw
  • 33
  • 1
  • 6
2
votes
0 answers

Python C_API: how to define nested classes?

I'm currently writing a C extension module for python using the "raw" C-API. I would like to be able to define "nested classes" like in the following python code class A: class B: def __init__(self): self.i = 2 def…
Serge Weinstock
  • 1,235
  • 3
  • 12
  • 20
2
votes
2 answers

Why is PyObject_Print crashing?

I've been playing with the Python 3.3 C-API to see if I could possibly use it in a planned upcoming project, and almost immediately ran into problems. Even code this simple crashes with 0xc0000005 as the return: #include #include…
2
votes
1 answer

Berkeley DB: stuck at futex_wait because of previous abnormal quit during c api call

I'm programming in C, using berkeley db 4.3 (/usr/lib64/libdb-4.3.so) on RHEL5.6 with kernel 2.6.18-238_xen_AMD64. In my tests (writing 1,000,000 key/value pairs), if one process quitted abnormally (ctrl + c, kill, or assert fails) while an…
felix021
  • 1,936
  • 3
  • 16
  • 20
1
vote
2 answers

Get a File Pointer from a Tcl_Channel using the Tcl C API

I want to operate on a file from C using the tcl C API. From within tcl, this is what I would do: % set file [open "my_file"] file3 % myfunc::load $file where myfunc::load is from a C extension: #include #include #include…
Lukas
  • 13
  • 3
1
vote
0 answers

How to free ruby object allocated through rb_marshal_load through C api?

I have this code which takes bytes from stdin and then tries to unmarshal (basically deserialize) that data through the rubys c api rb_marshal_load function: #include #include "ruby/re.h" #define MAX_INPUT_SIZE 120 VALUE…
1
vote
1 answer

C API: Error allocating / deallocating memory for array

I'm in the process of implementing an API for C. The code base itself is purely written in C++ and I only plan to offer said interface for any consumer using C. The interface is defined in a .h file, whereas the implementation itself is written in…
Xershy
  • 177
  • 11
1
vote
2 answers

Sharing Python multiprocessing shared Value with C extension

I have two processes in python that share a single boolean flag: from multiprocessing import Process, Value class MyProcess(Process): def __init__(self): self.flag = Value('B',false) # [...] def run(self): while…
Buzz
  • 1,102
  • 1
  • 9
  • 24
1
vote
1 answer

C-API register a ufunc loop against builtin ufunc

I am looking to build a numpy extension module which declares a new structured dtype and provides the necessary inner ufunc loops to allow built-in math operations to be performed on it. Following the guide on creating your own ufunc, I have been…
garryod
  • 21
  • 3
1
vote
0 answers

Python C API - catch call to non-existent function

I need to do some processing in the C backend during runtime. So what I want to do is, to define a C callback that'd get called each time there's a call to a non-existent python function. For example: // C code PyObject* callback_func(PyObject*…
Insane
  • 31
  • 4
1
vote
1 answer

How do I read OpenVINO IR models from memory with the OpenVINO C API

I am having trouble reading OpenVINO IR networks (XML and bin) from memory using ie_core_read_network_from_memory() in the OpenVINO 2021.4 C API ie_c_api.h. I suspect that I am creating the network weight blob wrong, but I cannot find any…
mags
  • 489
  • 2
  • 11
1
vote
1 answer

Running several tests with single initialization/destruction of objects to test

TL;DR: is it possible with pytest to create an instance of an object and then run a battery of tests on the same instance ? I have a custom C API, that uses posix threads and does operations on serial ports. My API is an implementation of a…
ZimLeTux
  • 13
  • 2
1
vote
1 answer

Tensorflow c_api decision forest savedModel loaded but status is not TF_OK

I am using tensorflow decision forests. I trained my model using Python and saved the model with SavedModel format. Then for inference I am trying to load the model in C using tensorflow C_API. I found that for this task I need to load the decision…
hpirlo
  • 133
  • 1
  • 12
1
vote
0 answers

Returning an error instead of raising it from python C API

Whether or not it is a good idea (and it probably is considered bad practice), I sometimes return an Error in python instead of raising it. def fnA( some_param ): # use some_param in complicated thing if some_param is None: return…
ghlecl
  • 3,127
  • 1
  • 16
  • 15
1
vote
1 answer

why does python import causes an error with PyImport_ImportModule but not with python interpreter

I have a python module mymodule that contains an import psutil statement. I can run it using python interpreter without any errors. However, I fail to load it with PyImport_ImportModule("mymodule") (from python C API), due to an undefined symbol in…
jsofri
  • 227
  • 1
  • 10