Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
Questions tagged [python-extensions]
323 questions
0
votes
0 answers
How to call a python method that returns a queue from C++ using boost (non-sclar type error)?
I have a method in python that's implemented like this :
class MyClass:
def __init__(self, i, j, k):
self._i = i
self._j = j
self._k = k
def generate_queue(self, max, min):
# do stuff
return…

qwerty_99
- 640
- 5
- 20
0
votes
0 answers
Python C++ module causing a core dump when accessing the same PyObject* attribute more than once
So I've finally managed to import the C module into python. However, I'm getting a core dump when I try to access the attribute of an object more than once. Here's the code:
node.h:
#pragma once
#include
#include…

qwerty_99
- 640
- 5
- 20
0
votes
0 answers
dynamic module does not define init function error when importing .so file compiled with boost python (Python 3.7)
This might have already been posted somewhere else but I couldn't find anything that worked. I have the following libraries / tools installed :
boost:
boost-python36.x86_64
boost-python36-devel.x86_64
boost-python36-static.x86_64
Python…

qwerty_99
- 640
- 5
- 20
0
votes
1 answer
Package C source files along with a Python package
I have a C library I am writing, and my goal is to be able to package and distribute that C library via a python package on PyPI. The concept is, it's a combination of Python code, an extension module, and a C library. I want the user to be able to…

Josh Weinstein
- 2,788
- 2
- 21
- 38
0
votes
0 answers
What is the C-API interface to create built-in array object in Python?
I am working on a Python C-extension code. Currently, a 1D C-array is converted to a Python List. Now I need to convert an ND-array, described by a 1) data type, 2) shape (as a 1D integer vector, for example, 2x4x3 array), and 3) data binary payload…

FangQ
- 1,444
- 10
- 18
0
votes
1 answer
Correct way to use PyArray_SimpleNewFromData?
I am trying to create a numpy array in a python extension.
The call of PyArray_SimpleNewFromData gives me a segfault.
I am trying to fix it for hours, and now I am the point where I have no more idea on how that could occur. Here is a…

Árpád Magosányi
- 1,394
- 2
- 19
- 35
0
votes
1 answer
How to build a python package with a c extension as a wheel for docker
I am trying to build a python package with a c extension to be used in a Docker container.
I create a python wheel as follows:
python install bdist_wheel
and the package looks (more or less) like
cpack
__init__.py
/cpp
__init__.py
…

Mike
- 3,775
- 8
- 39
- 79
0
votes
0 answers
When I run my python code in VS code it displays the output in the Terminal tab and not the Output tab
Currently using VS Code version 1.43.2 and Python 3.8.1. I want to know how will I make my codes display in the Output section and NOT the Terminal section when I ran them

Rakim B'Liwena
- 21
- 3
0
votes
1 answer
Proper way to call a different method from the same C-extension module?
I'm converting a pure-Python module to a C-extension to familiarize myself with the C API.
The Python implementation is as follows:
_CRC_TABLE_ = [0] * 256
def initialize_crc_table():
if _CRC_TABLE_[1] != 0: # Safeguard against…

Kamikaze Rusher
- 271
- 2
- 10
0
votes
1 answer
Linting in Visual Studio Code Python stymies real time error detection
I've used other editors (Spyder) where linting is real time, and it's incredibly useful to catch coding errors in real time. I'm not necessarily looking for real time, but even after I save, I have to wait 30 seconds or so.
I've seen this issue…

David Miller
- 512
- 2
- 4
- 17
0
votes
1 answer
Getting a SIGSEGV when calling python3 extension module function operating a Py_buffer
I'm toying around with Python C extension modules and I've got this simple function:
static PyObject *e_parse_metadata(PyObject *self, PyObject *args) {
Py_buffer buf;
if(!PyArg_ParseTuple(args, "y#", &buf)) {
// interpreter…

bool3max
- 2,748
- 5
- 28
- 57
0
votes
1 answer
How can I force setuptools detect that my package is platform specific?
I'm working on improving the setup.py script for an open source package that supports various platforms.
On Linux, the package defines a setuptools.Extension for some C code that needs to be built alongside the Python code. This produces a wheel…

rgov
- 3,516
- 1
- 31
- 51
0
votes
1 answer
Python application leaking memory, but Valgrind says no
I have a long-running Python app which scans many megabytes of files in a loop every few minutes. Over the course of a day I see that it gobbles up gigybates of memory, and in the end I have to kill and re-start it. Of course I'm suspecting a C…

musbur
- 567
- 4
- 16
0
votes
1 answer
How to build an extension in Python debugging environment?
I'm trying to debug a Python extension that I wrote. In order to enable some memory debugging features I downloaded and built a Python version, which worked just fine. Now I'm trying to build my own package using that environment, but it fails due…

musbur
- 567
- 4
- 16
0
votes
1 answer
Why does this Py_DECREF cause a segfault?
I'm chasing an annoying segfault bug in a Python extension. Drilling down to the core I first created a standalone C version of the extension, and while trying to further reduce the problem, I've ended up with this. It is the complete…

musbur
- 567
- 4
- 16