Questions tagged [python-bindings]
86 questions
0
votes
1 answer
Explicitly defaulted comparison operators in Cython
I want to wrap a C++ struct which has a comparison operator using Cython:
struct myStruct {
float a;
float b;
float c;
float d;
bool operator==(const myStruct &myStr) const = default;
};
I am struggling to figure out how to perform the…

devOrange
- 11
- 2
0
votes
0 answers
Pybind11 and shared libraries
I am just starting out with Pybind11 for python bindings with C++ code. Using CMake, the C++ files having functionalities to be imported in python are compiled to a .so(shared library) file in Linux. My question is that after compilation do the .so…

Tarique
- 463
- 3
- 16
0
votes
0 answers
Python Bindings Methods C++ Python
I have read many articles about methods (ctypes, cython, pybind11, etc.) of binding Python code with C++, more specifically using functions written in C++ from Python.
Recently I have read about the concept of "shared memory" between C++ and…

user
- 1
- 1
0
votes
0 answers
Sqlite3 error when non-command typed in Ubuntu terminal
When you typed gibberish input in terminal this always happen:
some@user:~/home/myfolder$ a
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in
from CommandNotFound import CommandNotFound
File…

veekzee
- 23
- 8
0
votes
1 answer
Binning in python with missing values
I have to create bins based on age. There are some missing values (nan) that need to be changed as "N/A and assign to a new category as "Not_Availabe". I filled in the missing values and then transformed the strings to float.
Students.loc[:,…

Mo_Phy
- 1
0
votes
1 answer
Pybind11 is slower than Pure Python
I created Python Bindings using pybind11. Everything worked perfectly, but when I did a speed check test the result was disappointing.
Basically, I have a function in C++ that adds two numbers and I want to use that function from a Python script. I…

IceCode
- 177
- 1
- 13
0
votes
1 answer
Issues with communicating with USB device through Ctypes and precompiled binaries
I am having issues using ctypes to connect with a gaussmeter (F.W. Bell 5180). The manufacturer provides DLLs for the interface and a header file called FWB5180.h:
FWB5180.h:
// The following ifdef block is the standard way of creating macros…

bpound
- 28
- 5
0
votes
1 answer
Creating Python bindings for a large quantity of C++ Qt Libraries
Question in short:
Do you maybe know, or have any idea how I could implement the below mentioned, existing libraries in Python, whether that be through bindings or any other possible solution?
Description:
I'm working on a project and I have a very…

BaKiForHire
- 1
- 3
0
votes
1 answer
PYBIND11: Make changes to class object value in another c++ thread when python interpreter is embedded and running in another thread
I am just printing the value of car1.vehicle_id in python. I want it to print "1234" for the first 2 seconds and then when the value is changes in another thread to " 4543" the change should take effect in python. Is this possible or is there a…
0
votes
0 answers
C++ python binding: failed to import cv2
I m using Ubuntu 20.04, python 3.8 and developing a C++ project in Qt Creator. I m trying to call a python file from C++ code. I have created an environment in conda and calling the py file. There is segmentation fault occurring when I m attempting…

surajj4837
- 49
- 1
- 10
0
votes
0 answers
Python binding of a third party c++ library
I have a third party C ++ API, dynamic library (.so) for Linux with a header file.
My question is, can I directly write a bind file and use boost.python to create python bindings. I tried doing it and I added just one function to my bind.cc file…

S.Max
- 21
- 3
0
votes
2 answers
How do I allow NoneType Arguments OR a callback function to be passed to a function in ctypes
I've started writing a very simple Python binding around a C/C++ library, which I can't share here for legal reasons as I don't have permission.
This contains a WINFUNCTYPE() as a callback, which can then be used to decorate a function to use as the…

jbflow
- 578
- 2
- 16
0
votes
1 answer
How do I call a C function from a library installed with `apt install` using ctypes?
I am trying to call ulc_width_linebreaks from unilbrk from GNU's libunistring (a C function) on my Python strings using the ctypes module. libunistring is available on Ubuntu, and I've installed it with sudo apt install libunistring2…

Boris Verkhovskiy
- 14,854
- 11
- 100
- 103
0
votes
1 answer
Why does sip complain about unexpected type 'str' when using a char *?
I am trying to use sip to create python bindings from c++ to python 3.8.
I found a simple example here
and updated it to get it working with sip version 5.4 which I installed with pip.
Details can be found here
I changed the names from word to…

JohnnyWaker
- 33
- 7
0
votes
2 answers
Wrapping C code with python on the fly with CFFI/Cython
I am working on a project which requires me to create some wrappers in Python for the C library that I need to call from Python. For context, the C library I am using is a bunch of header files (.h) and statically linked library files (.a)
I have…

abisheksampath
- 376
- 8
- 23