Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
79 views

Python's C-extension with numpy randomly crashes after a few calls (5~10) from python code

To speed up custom MFCC calculations, I had to write some code in C, wrap it with Python's C API & numpy's C API, and compile it with disutils.core in order to import it from python code. I was ...
FloopyBeep's user avatar
1 vote
1 answer
94 views

generalized ufunc on two arrays with one non-matching dimension

I want to write a numpy gufunc python extension using the numpy C-api that takes two matrices of arbitrary dimensionality, takes the mean across one dimension, and then subtracts one result from the ...
Aaron Earle-Richardson's user avatar
0 votes
0 answers
36 views

What is the standard method to numpy extension create modules that support different array datatypes?

Assuming I have a C function I would like to wrap by the Nympy(Python)-C API to create a Python extension module. This module should be capable of accepting Numpy array that can have multiple types ...
Gideon Kogan's user avatar
0 votes
0 answers
65 views

How to Import .py file with third-party package(like numpy) from C?

I'm using visual studio to import a python file from a c/c++ file to use a function(named lalala) defined in PythonApplication7.py. I'm trying to use Python-C-API to do this. The C file is: #include &...
Dzhou's user avatar
  • 1
0 votes
0 answers
47 views

Recursive Datatypes w/ Numpy C-API?

I'd like to use the numpy c-api to write a datatype that's a tree structure, with pointers to children. I initially thought this possible without being a flexible datatype, since I don't need a ...
bockyboh's user avatar
-1 votes
2 answers
401 views

What is the corresponding C-api name of the following numpy function in Python

I would like to write a C extension lib for Python, aiming to replace Python code with C. The Python codes has several lines like below: import numpy as np a = np.array([1,3,12,0.43,234,-3,-4]) b = a[[...
dongrixinyu's user avatar
4 votes
1 answer
226 views

Linking to numpy's linear algebra libraries in C extension

I am writing a C extension and would like to take advantage of the linear algebra routines that the numpy libraries are linked to. Is there a cross platform method of getting the path for these? I've ...
vlovero's user avatar
  • 300
0 votes
1 answer
283 views

Include <arrayobject.h> header path to compile C python extension in build pipeline using cibuildwheels

I'm developing a python package that contains a C extension. I want to deploy a release for each operating system (linux, windows, macOS) using cibuildwheel. The C extension uses the arrayobject.h ...
Jorge Morgado's user avatar
1 vote
1 answer
1k views

Operate on Numpy array from C extension without memory copy

I'm new to C extensions for NumPy and I'm wondering if the following workflow is possible. Pre-allocate an array in NumPy Pass this array to a C extension Modify array data in-place in C Use the ...
Master Yogi's user avatar
1 vote
1 answer
532 views

How to acquire GIL for the new thread state created using embed python in C++ application

I have a C++ application where we provide a python editor(which uses python 3.7), users can input and execute the python code in the editor. Following is the sample code where we are creating a new ...
Revanth's user avatar
  • 69
4 votes
0 answers
68 views

Dymola Segfault in external C function with Python API when using time and numpy [duplicate]

We execute Python code from Dymola via the C/Python API. Therefore we used that tutorial. The tutorial works as shown, but when we combine Dymolas built-in time variable and Pythons Numpy library, we ...
dr_auerbach's user avatar
0 votes
0 answers
447 views

Numpy Python/C API - PyArray_SimpleNewFromData hangs

I'm figuring out the Python/C API for a more complex task. Initially, I wrote a simple example of adding two ndarrays of shape = (2,3) and type = float32. I am able to pass two numpy arrays into c ...
Abarajithan's user avatar
1 vote
0 answers
146 views

Writing my own ufunc; ufunc not supported for the input types

I'm trying to write a C function that coverts numpy string array to a float array. How can I receive numpy's array in C as const char *? static void double_logitprod(char **args, npy_intp *dimensions,...
Saurav Bhattarai's user avatar
2 votes
2 answers
248 views

Precomputing strided access pattern to array gives worse performance?

I have a written a c-extension for the numpy library which is used for computing a specific type of bincount. From the lack of a better name, let's call it fast_compiled and place the method signature ...
Kevin's user avatar
  • 3,398
3 votes
0 answers
84 views

No objects of __all__ are defined in numpy.random subpackage, but no errors are thrown upon importing

Why all the functions listed in __all__ (of the init file) of numpy.random subpackage work even though they aren't defined there? I can imagine that they are written in C, but still when I do from ...
ankit's user avatar
  • 13

15 30 50 per page
1
2 3 4 5
8