Questions tagged [python-extensions]

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

323 questions
0
votes
1 answer

Building 64 bit Python extension on Windows tuple : undeclared identifier

I work on 64 bit windows with 64 bit python 2.7 and i am trying to compile my first c++ extension for python. At first i tried to use mingw but ran into many linker errors, so now i use c++ for python 2.7 with the windows7 SDK. It should be an…
Cebarik
  • 3
  • 4
0
votes
1 answer

What's the fastest way to use C/C++ in Python?

What is the fastest way to call C/C++ functions and use C++ classes? There are various methods to do this such as Python Extension Module (Python.h), Cython, SWIG, Boost, and etc. I've already implement C/C++ functions and C++ classes. Because…
Dayamre
  • 1,907
  • 2
  • 13
  • 10
0
votes
3 answers

Execute Regardless of the Type of Exception

I would like my program to exit regardless of the type of the exception that occurred. However, depending on the type of the exception, I want to log a different error message. How could I achieve this with less code repetitions? Following is the…
c00der
  • 543
  • 1
  • 4
  • 20
0
votes
0 answers

When building boost.python why do some files get 'python' in the name and others get 'python3'?

For example, if I run the following command: bjam --toolset=msvc-14.0 address-model=64 --with-python python-debugging=off threading=multi variant=debug toolset=msvc-14.0 link=static --stagedir=stage\x64-static-python35 stage 2 files are…
DNg
  • 422
  • 2
  • 15
0
votes
0 answers

How can I expose C++ classes in a Python extension? (Without resorting to boost.python or swig or cython)

I've followed this video tutorial on setting up a very basic C++ extension for python using Visual Studio. It's very straightforward and works quite nicely. https://www.youtube.com/watch?v=y_eh00oE5rI Here's what my code looks like. #ifdef…
DNg
  • 422
  • 2
  • 15
0
votes
1 answer

Python Extension Can't Use library_dirs

WHen specifying library_dirs in a Python distutils.core.Extension I get this error when trying to build: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/dist.py:263: UserWarning: Unknown distribution option: 'library_dirs' …
None
  • 3,875
  • 7
  • 43
  • 67
0
votes
1 answer

two-dimensional python dict with shared memory

I need to load data from a csv file or an excel sheet (with rows and columns) into a two-dimensional python dict. For example, if the data in an excel sheet looks like this: name age gender location 1 Jim 18 male China 2 Ross 18 …
He Li
  • 31
  • 5
0
votes
2 answers

Can't call method in Python C extension

I'm working on making my first Python C extension, which defines a few functions and custom types. The strange thing is that the custom types are working, but not the regular functions. The top-level MyModule.c file looks like this: static…
Nik Reiman
  • 39,067
  • 29
  • 104
  • 160
0
votes
1 answer

How to create and return a function object in a c extension module?

I am trying to write a python extension module where some of the functions are curried, but I am not quite sure how to go about doing so. The main difficulty being that I am not sure how to create and return a PyFunction object and how to then pass…
0
votes
1 answer

Equivalent of python lambda function for C (Python Extensions)

I'v written a Python extension module with C to speed up computation times. The first step is a 2D integration of a function f(x,y,k), which is very fast and allows me to integrate over y in [y1(x),y2(x)] and x in [a,b] whilst assigning a float to…
0
votes
0 answers

Importing python extension module loading already loaded shared library

I am getting an undesired loading of a shared library which has already been loaded. I have a binary(test_bin) which is supposed to load a shared library(libtest.so). Also, I have a C python extension module(extension.so) which also loads…
0
votes
3 answers

Passing a float array pointer through a python extension/wrapper – SndObj-library

So I'm feeling that Google is getting tired of trying to help me with this. I've been trying to experiment some with the SndObj library as of late, and more specifically the python wrapper of it. The library is kind enough to include a python…
JohanPI
  • 161
  • 9
0
votes
0 answers

How to access the data members in a python class object that was passed to C++?

Say I have a python class object: class A: pass o = A() o.a=8 # or any data type such as numpy arrays and I want to pass that python object to C++ extension: import cpp_lib cpp_lib.run(o) From the C++ side, I want to access the member of…
Hailiang Zhang
  • 17,604
  • 23
  • 71
  • 117
0
votes
1 answer

C Python Extension object type

Is there a way to find out the type of a Python Object in C extension? I need to pass a name(string) or a double value from script to my extension. I thought I could call parsetuple in my extension and get the argument into a Python Object(using…
HJR1
  • 1
  • 1
0
votes
1 answer

PyArg_Parse returning frame object instead of PyLongObject

I'm writing a Python Module using the C extension API and am trying to pass a long variable from Python into the C function and then from that get the raw PyLongObject used to represent this variable. I'm using the PyArg_Parse function to parse the…
ali2992
  • 129
  • 1
  • 2
  • 8