Skip to content
Advertisement

Tag: c++

How to debug crashing C++ library loaded in python project

I am attempting to figure out why calling a function in a dynamically loaded lib crashes python. I’m doing the following, I have a C++ function in a dynamic library file, which is loaded in python using ctypes. I then call the function from python: On MacOS, this works exactly as expected. Unfortunately on Windows 11, it does not. I’m

Implementation of stable_sort in python

In c++ there is a function stable_sort() function (It preserves the order ) .Is there any function in python like this ? Answer list.sort() is stable. From the documentation: The sort() method is guaranteed to be stable. A sort is stable if it guarantees not to change the relative order of elements that compare equal — this is helpful for

Subset algorithm behaves differently in Python than C++

The algorithm follows recursive approach, dividing the array in two parts: In first recursion the first part is neglected In second part the first part is added Code for C++ (Works Fine) Code for Python Answer In the C++ version, res is a by-value parameter, so a copy of the vector is made in each call. Python passes references to

Get quotient and residue from a division executing just one operation [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 months ago. Improve this question I need to know how can i get quotient and residue from a division executing just one operation, using python

pybind11 crashes (segmentation fault (core dumped)) while importing ONNX python module

I am using pybind11 in my C++ code. When I try to import onnx, my code crashes with Segmentation fault (core dumped). However, if I import onnxruntime, everything is well. Of course both onnx and onnxruntime are installed on my system via pip. The order of the import lines is irrelevant. Wherever it is, py::module::import(“onnx”) crashes with segmentation fault. How

String Slicing in c# using intervals

In python there are ways that allow you to access the string using an interval(slicing): Example Get the characters from position 2 to position 5 (not included): Is there something similar in c#? Answer In C# 8.0 (or higher) you can use ranges, e.g Or on old c# versions, Substring: Finally, you can use Linq, but it’s overshoot here:

Wrapping a C++ library using msl-loadlib in python

I am currently writing a wrapper for a C++ library. The library is a 32-bits dll file and I’m using 64-bits so I’m using msl-loadlib. I have a problem wrapping a function that has pointer parameters. Here is the header of the function in C++ and here the wrapper I wrote When I call Client.getMeasurement(parameters), I get the following error

float pointer in ctypes python and pass structure pointer

I’m trying to pass a structure pointer to the API wrapper, Where the struct is containing float pointer member. I’m not sure that how we can pass float pointer value to the structure. /Structure/ /wrapper/ Answer You can either create a c_float instance and initialize with a pointer to that instance, or create a c_float array and pass it, which

Advertisement