python-c-extension Questions

0

We have a package (rebound) up on PyPI that includes a C extension . The relevant part of the setup.py file looks like this (simplified): libreboundmodule = Extension('librebound', sources = [ 's...
Reform asked 31/8, 2015 at 14:35

2

Solved

Is it possible to create a Python 2.7 package using __init__.pyx (compiled to __init__.so)? If so how? I haven't had any luck getting it to work. Here is what I have tried: setup.py: #!/usr/bin...

4

Solved

I am trying to build lxml for Python 2.7 on Windows 64 bit machine. I couldn't find lxml egg for Python 2.7 version. So I am compiling it from sources. I am following instructions on this site htt...
Anastase asked 15/6, 2010 at 17:35

3

I'm trying to debug my C extension for Python 2.7. I use python2.7 debug build. I build my project with setuptools and my setup.py has such lines: ext_modules=[Extension("my.extension", ["my/_ext...
Menhaden asked 10/4, 2015 at 5:49

2

I am writing a c-extension for python. As you can see below, the aim of the code is to calculate the euclidean-dist of two vectors. the first param n is the dimension of the vectors, the second , t...
Intercede asked 1/4, 2015 at 16:59

0

When debugging a python extension in visual debugger, the raw interpretation of a python object in the inspector is not user-friendly. One can hardly see the real content in the object. Is there a ...

3

Solved

I'm writing a Python class in C and I want to put assertions in my debug code. assert.h suits me fine. This only gets put in debug compiles so there's no chance of an assert failure impacting a use...
Ribaldry asked 27/12, 2010 at 20:24

4

Solved

I'm writing a C extension to my Python program for speed purposes, and running into some very strange behaviour trying to pass in a 3-dimensional numpy array. It works with a 2-dimensional array, b...
Circe asked 22/3, 2013 at 17:9

1

It seems to me the buffer protocol is more for exposing Python buffer to C. I couldn't find a way to create a bytes object using existing buffer without copying in C. Basically what I want is to ...
Pa asked 20/6, 2014 at 22:38

1

I am having difficulty getting my testing framework to work for a C-extension module for both Python2 and Python3. I like to run my docstrings through doctest to make sure that I am not feeding my ...
Chiachiack asked 5/8, 2014 at 5:18

3

Solved

I have a C extension in which I'd like to use OpenMP. When I import my module, though, I get an import error: ImportError: /home/.../_entropysplit.so: undefined symbol: GOMP_parallel_end I've c...

1

Solved

I need to create a new list via the python C API containing new copies of objects of a Quaternion class I've written (in C++). [Actually, I'd really like a numpy array, but any sort of sequence wou...
Tirewoman asked 23/10, 2013 at 3:51

1

Solved

Using the C API, I would like to create a numpy array containing objects of type Quaternion, which is a class I've written in C++. I already have an array of these (actually a std::vector), and I w...
Crematorium asked 23/10, 2013 at 4:34

1

I am manually modifying the shape and strides of NumPy arrays which may (or may not) invalidate the contiguity flags. Do I have to then manually check whether the strides match the values you wo...
Aviary asked 20/9, 2013 at 23:23

3

Solved

This is a simple example from the python documentation (http://docs.python.org/extending/extending.html): static PyObject * spam_system(PyObject *self, PyObject *args) { const char *command; int...
Unmake asked 16/2, 2012 at 17:37

1

Basically I want to make a Python program call functions written in C. So (as far as I know) my options are: CTypes/CFFI Create a DLL/SO/DyLib containing the C functions and access them using ...
Annuity asked 19/7, 2013 at 21:21

1

I'm a bit confused about when I'm supposed to call PyEval_InitThreads. In general, I understand that PyEval_InitThreads must be called whenever a non-Python thread (i.e. a thread that is spaw...
Applicant asked 17/2, 2013 at 0:38

1

Solved

I'm writing a C extension and I'm quite lost on how to receive a dict as an argument. As the docs don't have any specifics on how to achieve this I tried to parse the argument as a Python Object an...
Biisk asked 7/11, 2012 at 18:47

2

I'm writing a Python C-Extension without using Cython. I want to allocate a double array in C, use it in an internal function (that happens to be in Fortran) and return it. I point out that the C-...
Standridge asked 25/9, 2012 at 12:22

1

Solved

I'm writing an implementation of the in-place add operation. But, for some reason, I sometimes get a read-only buffer as result(while I'm adding a custom extension class and an integer...). The r...
Degrade asked 10/8, 2012 at 7:58

4

Solved

I need to make a copy of a socket module to be able to use it and to have one more socket module monkey-patched and use it differently. Is this possible? I mean to really copy a module, namely to...
Tact asked 23/6, 2012 at 15:59

2

Solved

As I understand the relationship between C and C++, the latter is essentially an extension of the former and retains a certain degree of backwards compatibility. Is it safe to assume that the pytho...
Rhombohedral asked 28/4, 2012 at 22:31

1

Solved

From what I can tell, the difference between PyList_SetItem and PyList_SETITEM is that PyList_SetItem will lower the reference count of the list item it overwrites and PyList_SETITEM does not. Is...
Rounded asked 24/4, 2012 at 20:12

3

Solved

I'm just starting to play with Python C extensions and am curious as to why a C function, which is callable from Python must take 2 PyObject* arguments and return a PyObject*. I wrote the following...
Aalesund asked 21/4, 2012 at 4:50

3

I have noticed that several mature Python libraries have precompiled versions for most architectures (Win32/Win-amd64/MacOS) and versions of Python. What is the standard way to cross-compile your e...
Gatecrasher asked 4/1, 2012 at 4:11

© 2022 - 2024 — McMap. All rights reserved.