Questions tagged [python-extensions]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

323 questions
1
vote
0 answers

Can't load python extension from installed package

I'm having some problems understanding the importing of a python package with extensions that was installed with setup.py. The packages is 'gmes', and it has 4 extension modules which are .so files. The first attempt to load the package gmes gives…
1
vote
0 answers

Python3 extensions - working with files

I am working on a Python extension module in C++ and I have a FILE object and I want to propagate it Python code so I can work in some way (reading, writing, etc). In Python2 it was possible to use PyFile_FromFile and create a Python object. Since…
dohnto
  • 584
  • 5
  • 13
1
vote
1 answer

Obtain current Python call stack from within SWIG wrapped C++ function

if I call a SWIG-wrapped C/C++ function from Python, is it possible to obtain the current call stack? I would like something similar to the result of ''.join(traceback.format_stack()), but I don't want to pass this from Python to my C/C++ functions…
shaoyl85
  • 1,854
  • 18
  • 30
1
vote
2 answers

Check if class object is defined in extension module

Given a class object in Python, how can I determine if the class was defined in an extension module (e.g. c, c++, cython), as opposed to being defined in standard python? inspect.isbuiltin returns True for functions defined in an extension module,…
1
vote
1 answer

building python C++ extension -- how to know if a linked library cannot be found

I downloaded a python-wrapped C++ code and am trying to build it from source, and it compiles without errors, but when I run the end result, it fails in a way that seems to suggest that it did not find at least one of the libraries that it was…
Steve Byrnes
  • 2,210
  • 1
  • 20
  • 25
1
vote
1 answer

Building cython with multiple pyx-files on Windows 8 for python 2.7

To build I use distutils: python setup.py build_ext --inplace Building a simple pyx-file works (setup.py): from distutils.core import setup from Cython.Build import cythonize setup( ext_modules = cythonize('test.pyx') ) Building more than one…
Asken
  • 7,679
  • 10
  • 45
  • 77
1
vote
1 answer

Which tool (gdb? xcode? pdb? etc) can I use to find a memory leak in a C-extended python program?

I am writing a python program that includes an extension module written in C. The extension module defines a function that is used in my program continually. I have a memory leak somewhere in my program, but I don't know how to find it. I have…
Faiyam Rahman
  • 305
  • 2
  • 4
  • 8
1
vote
0 answers

Python windows extensions vcvarsall.bat incorrect windows SDK registry key

I am having a lot of trouble trying to build Python extensions on a particular machine. It has both VS2008 and VS2013 installed along with, what I believe to be, the correct C/C++ libraries, etc. I am also comparing two machines which have roughly…
SimplyKnownAsG
  • 904
  • 9
  • 26
1
vote
0 answers

Python C Extension OpenMP

i am getting a segmentation violation in the python interpreter when trying to access a variable which is returned by my own OpenMP C++ extension. All the solutions which i have found are either using ctypes or cython (which i cannot use).…
Philipp
  • 535
  • 1
  • 6
  • 16
1
vote
1 answer

C++ static member initialization in python extension module

Short version I don't understand how to reliably initialize static members for a python extension. In particular, how can I ensure a particular load order for code from different compilation units, so that certain dependencies are satisfied? Long…
Mike
  • 19,114
  • 12
  • 59
  • 91
1
vote
3 answers

error: unknown file type '.hpp' in distutils extension module

I'm trying to generate Python bindings for some C++ code using SWIG. It created some blah_wrap.cxx and blah.py files. I then created this setup.py from distutils.core import setup, Extension ext = Extension('_ev3', sources=[ …
Pepijn
  • 4,145
  • 5
  • 36
  • 64
1
vote
1 answer

Python/Numpy C++ extension: memory issue

I wrote a python extension in C++ to work with numpy arrays. I have a memory issue. I have a 3D numpy array with values > 0 before I call the extension. Once I am in the extension I get the numpy array using this function: PyArrayObject * myArray…
user1314776
  • 155
  • 2
  • 8
1
vote
2 answers

Relative include paths when building an RPM for a python extension using distutils

Using python 2.6, I'm attempting to build an RPM for a python C extension module. The setup.py that I'm using contains something like: from distutils.core import setup, Extension foo_ext = Extension('foo', sources=['foo.c',…
Dave Challis
  • 3,525
  • 2
  • 37
  • 65
1
vote
2 answers

Benefit of converting Python method to C extension?

A relatively simple question: If I convert a CPU-bound bottleneck method from Python to a C extension (roughly implementing the same algorithm), How much increase in speed, and performance should I expect? What factors determine…
rivenmyst137
  • 345
  • 1
  • 4
  • 10
1
vote
3 answers

How to write python extensions in pure asm and would it be efficient?

I have medium amateur skills in Python and I'm beginner in asm and haven't any knowledge of C-language. I know that python C-extensions must follow specific interface to work fine. Is this possible to write python extension in pure Assembly with the…
Крайст
  • 776
  • 1
  • 9
  • 22