Questions tagged [cython]

Cython is a superset of the Python language for quickly generating Python C extensions.

Filter by
Sorted by
Tagged with
0 votes
0 answers
13 views

For Python Cython wrapper of C/C++ library, how to delegate object's instantiation back to additional C++ code and expose it back to python

In my python project (let's call it project A) I use a C++ project (let's call it project B) that exposes C++ API, and also provides python wrapper, that is created with Cython. In the project A, I ...
Aisec Nory's user avatar
1 vote
0 answers
26 views

Linking boost (c++) using cython

I am getting this error when i try to run a test after implementing a functionality in my c++ code. tests/pipeline/feature_extraction/test_rolling_windows.py:5: in <module> from pipeline....
Saif Ali Khan's user avatar
-3 votes
1 answer
20 views

@cython.cdivision(True) causes "math domain error" in weird scenario

Running a Jupyter notebook in VSCode, I am getting bizarre behavior with the Cython unprotected division directive. Starting the session with %load_ext cython, run: %%cython import math cimport ...
feetwet's user avatar
  • 3,234
0 votes
0 answers
15 views

What is alternative for DEF in jupyter cython

I am using DEF so that I can efficiently allocate arrays in Cython that I'm running in jupyter notebooks, like this (pointless) example: %%cython DEF iterations = 1000 def test(): cdef int a[...
feetwet's user avatar
  • 3,234
0 votes
0 answers
36 views

Compiling a C generated file using Cython

I am trying to compile a generated .c file from a .py file using cython --embed -o hello.c hello.py I have a hello.c generated successfully but whenever I try to compile that using gcc gcc -Os -I <...
Mostafa Ahmed Asaad's user avatar
0 votes
1 answer
28 views

How can I create a single Python package from a Cython files (.pyx) that includes multiple .pyx files using build package

I'm trying to build a python package of a collection of Cython functions under one package name, using include statement in Cython, following the idea of this. Here's the file organization (root ...
ysroh260's user avatar
0 votes
1 answer
31 views

No module named 'bbox'

I am working on one project which should be re written, so i did not write from beginning, and there is no opportunity to ask person who wrote the code. I have next part of code: from ..cython.bbox ...
aestetor's user avatar
1 vote
1 answer
66 views

Error compiling Cython file: Invalid types for `'>'` (`float64_t[::1]`, `float64_t`)

Context I am attempting to cythonise a function to replace a filtering operation on an extremely large pandas.DataFrame (100,000,000 rows). Currently it compares values in the df columns (Z, T, M) ...
Buzz B's user avatar
  • 87
-3 votes
1 answer
22 views

Kivy and Cython game [closed]

I would know if it actually a great deal to make a game in Python using Kivy (OpenGL) and Cython. So is it or not ? If not what should I use for making a cross-platform (computer/mobile) game using ...
switchcodeur's user avatar
0 votes
0 answers
31 views

linker input file unused because linking not done with cython

This is the setup for the installation of cython module: from setuptools import setup, find_packages, Extension from Cython.Distutils import build_ext from Cython.Build import cythonize setup( ...
CuriousPanda's user avatar
0 votes
0 answers
29 views

Unable to pip install eif on Mac - no module named 'numpy' on install but numpy is installed

my windows laptop just died and I pulled the code to run it from my M1 Macbook. I'm horrible with setting environments. I use visual code studio. I've created a new venv, run pip install numpy, pip ...
The App Investor's user avatar
0 votes
1 answer
38 views

Circumvent the non-standard behaviour of __getattr__ in a Cython extension class

I am writing code, which I want to work both with vanilla Python and as part of a Cythonized module. I have a cdef class that I want to behave normally, but on which I want to override the behaviour ...
Szymon Łopaciuk's user avatar
-1 votes
0 answers
16 views

How to make executable from python code instead pyinstaller? [duplicate]

Is there any other way to make a binary executable from py files without using pyinstaller? Pyinstaller increases latencies when it gets executed and takes time to download dependencies and set them. ...
Jayesh Desai's user avatar
1 vote
1 answer
28 views

How to assign a multidimensional array to a sub-block of a 2d array

I want to take a big 2d-array and fill it with values by inserting sub-blocks (read: smaller 2d arrays) until the big array has been filled. I want to do this as fast as possible, so I try to use what ...
Mikke Mus's user avatar
  • 131
1 vote
0 answers
16 views

Cython: Signature not compatible with previous declaration

File orderbook.pyx: from .constants import Side cdef class OrderBook: cpdef set_order(self, side: Side, order: dict): pass File orderbook.pxd: from .constants import Side cdef class ...
baldr's user avatar
  • 2,911
0 votes
0 answers
19 views

Cython cannot make exportable

I am trying to create a Cython package, comprising of several files, but I cannot make them exportable. Say, directory structure is the following: packagename_src/ - constants.pxd - constants....
baldr's user avatar
  • 2,911
0 votes
0 answers
28 views

Cython quadrature problem : big array element access

My problem is that I want to to a 3d quadrature on some function. The objective is to compute electronic-integrals. The electron-electron potential integrals being the problem now. I am using 20 Gauss-...
L Maxime's user avatar
1 vote
0 answers
51 views

How to make matrix multiplication with cython + scipy.linalg.cython_blas as fast as numpy.dot?

import numpy as np I want to multiply two matrices a = np.random.randn(n_dim, n_dim) + 1j * np.random.randn(n_dim, n_dim) b = np.random.randn(n_dim, n_dim) + 1j * np.random.randn(n_dim, n_dim) My ...
Maryks's user avatar
  • 11
0 votes
0 answers
39 views

Fastest way to grow 2D Arrays in Cython

Consider a Cython extension class that takes some input and then runs a method to build out a 2D array. One of the final solution's dimension is known at instantiation (based on user input), however ...
Oniow's user avatar
  • 307
0 votes
0 answers
47 views

why i can't install surprise in my device

I get this error when I try to use pip install scikit-surprise: pip install scikit-surprise Collecting scikit-surprise Using cached scikit-surprise-1.1.3.tar.gz (771 kB) Installing build ...
محمد 's user avatar
0 votes
1 answer
34 views

XOR operation in Cython within a nogil context for hashing a vector with a hex

I am trying to define a hash for a sorted vector of type size_t. As part of the solution, I use an XOR operation. cdef size_t vector_hash(const vector[size_t]& v) noexcept nogil: ""&...
ajl123's user avatar
  • 1,182
0 votes
1 answer
49 views

Problem with installing auto sklearn package [duplicate]

I wanted to install auto sklearn package for Jupyter Notebook with !pip install auto-sklearn I tried it on Anaconda prompt too but didn't work and I faced an error which is discussed here. Citation: ...
Etemon's user avatar
  • 55
0 votes
0 answers
30 views

arrow/python/platform.h: No such file or directory

Iam using apache arrow with C++ and Iam using cython to make an interface between some of the C++ function and python when I try to build the setup file I get this error message : arrow/python/...
Mostafa's user avatar
0 votes
0 answers
43 views

spaCy 3.0.6 installation error on AWS notebook instance

I have been successfully installing spaCy 3.0.6 numerous times (without any issues) in the past. However, recently after restarting my AWS notebook instance, and trying to install spaCy 3.0.6, I ...
user22461153's user avatar
0 votes
1 answer
50 views

Cython callback from C++

I am trying to have c++ calling a callback function written in cython (function pointer). But the values I got inside Cython from C++ seems to be garbage value, and results in a seg fault. Here is the ...
George Huang's user avatar
0 votes
2 answers
40 views

Python / Numba create histogram from ranges

I want to create a histogram (1d) from given ranges and I want it to be fast. This is why also cython and numba can be taken into consideration. Given are two boundaries, weights and a stepsize. For ...
Scooba's user avatar
  • 11
1 vote
0 answers
39 views

How to use scipy LowLevelCallable in my own code?

Scipy has this neat feature called LowLevelCallable: they are wrappers around compiled optimized functions (implemented in C or Cython for instance) that can be passed to numerical intensive functions ...
G. Fougeron's user avatar
2 votes
1 answer
102 views

Cython returned memoryview is always considered uninitialized

Similar to Cython Memoryview as return value, but I didn't see a solution other than hacking the generated C code. I'm using Cython 3.0, but it looks like the result is the same with <3. Here's an ...
djhoese's user avatar
  • 3,567
0 votes
0 answers
19 views

Issue with Cython Compilation and File Movement in setup.py

I'm currently working on a project that involves compiling Cython .pyx files into shared object (.c) files using setup.py. Additionally, I've created a test suite named test_setup.py using pytest to ...
vladandreevza5557's user avatar
0 votes
0 answers
19 views

Trouble Testing setup.py for Cython Extension Module - ImportError and Test Failure

I'm currently facing challenges while attempting to test the setup.py script for a Cython project using pytest. Despite following guidance and examples, I'm encountering an ImportError and test ...
vladandreevza5557's user avatar
0 votes
0 answers
65 views

Cytools failing to build metadata

Im using python 3.11 and coding in vs code while trying to install some requirements im getting the following error ` Collecting cytoolz==0.11.2 (from -r requirements.txt (line 11)) Using cached ...
zaid ragie's user avatar
0 votes
0 answers
36 views

ImportError with embedded python module when linked to larger shared library. undefined symbol: PyLong_AsLongLongAndOverflow

I wrote a C wrapper to access the ezdxf Python package from my C++ program using the embedded interpreter. When I compile the wrapper by itself it works as expected (loads the module below which loads ...
Sean McBride's user avatar
0 votes
0 answers
40 views

How to transpose a Cython memoryview slice?

I am trying to calculate the transpose of a Cython typed memoryview slice (eg. a 2D part of a 3D array). I am encountering a transpose error specifically when I try to transpose a 2D slice of a 3D ...
Eric's user avatar
  • 25
0 votes
1 answer
18 views

How to use a prange with a python function in cython?

This question is closely related to: 53641278. In the comments of that question there was a suggestion by @ead to use the approach from comment by @DavidW of question 53619438. In my problem, I am ...
zchmielewska's user avatar
0 votes
0 answers
53 views

Having trouble creating an extension type with global C struct variable

I am trying to create a cython wrapper around a C project. I have been successful at creating some function calls (with help from @DavidW but now I want to wrap much of the API in a single class. ...
Mark Wilson's user avatar
1 vote
1 answer
42 views

Cython - Cannot convert Python object argument to type 'float *'

I am using Cython to write a Python API to a C project. In the C project there is the following relevant code in the header file: #ifndef EN_API_FLOAT_TYPE #define EN_API_FLOAT_TYPE float #endif ...
Mark Wilson's user avatar
-2 votes
1 answer
60 views

Python/Tkinter/Cython/PyInstaller: menu bar not clickable in MacOS

When I run the following test program using the Python interpreter from the MacOS Terminal, it works as expected. When I Cython it and create an executable using PyInstaller, and run it from the ...
Rodney Boyd's user avatar
0 votes
1 answer
25 views

Cannot pass C array as memoryview in Cython

Here is the example pyx file # yy.pyx def foo(double[::1] args): cdef double[3] v = [args[0], args[1], 0] bar(v) def bar(double[::1] args): pass and the main (I run in ipython for ...
nos's user avatar
  • 19.9k
1 vote
0 answers
23 views

How can I resolve 'cimport' errors in Cython? [duplicate]

In a .pyx Cython file, I am trying to import several C functions as below: from libc.stdlib cimport atof from libc.string cimport strlen, strsep I get an error: error LNK2001: unresolved external ...
jbiz's user avatar
  • 43
1 vote
2 answers
62 views

Why does the memoryview assignment from array have python interactions?

When compiled with cython -a my-file.pyx, this simple line of cdef is annotated as yellow in the html file. # my-file.pyx from cpython.array cimport array def f(double[:] xyz): cdef double[:] ...
nos's user avatar
  • 19.9k
1 vote
0 answers
19 views

How to combine code-coverage from unittests using Cython and conventional C/C++ test frameworks

I am using Cython to wrap existing C-Code related to algorithmics, in order to perform unit tests or run simulations using Python. However, I also have conventional unit tests in C/C++ (Catch2) for ...
fkh746351's user avatar
0 votes
1 answer
37 views

.pyd not showing the modules anticipated

I have a freenect.pyd file compiled from c programs however when I import the function and call dir(freenect) its output is just ['__doc__', '__file__', '__loader__', '__name__', '__package__', '...
hugo's user avatar
  • 31
0 votes
0 answers
33 views

Trying to static link with a Python3 Cython C extension

So, i am trying to static link a cython app so that i can deploy it on my server clusters without having to install a lot of libraries. I can compile the binary fine, but when i run it on another ...
Robbert Klapper's user avatar
1 vote
0 answers
29 views

Wrapping nested C++ function pointer calls in Cython

I am trying to wrap the biteopt optimization algorithm in Python using Cython for potential future inclusion in SciPy. I do not really understand C++ though, so I am having trouble compiling. This ...
Tyrion's user avatar
  • 23
0 votes
0 answers
44 views

How to remove python interactions for numpy array operations in cython

I have a simple numerical function for cython. Following the numpy tutorial, I got import numpy as np from cython.view cimport array as cvarray cpdef double[:, ::1] invert_xyz(double[:, ::1] xyz, ...
nos's user avatar
  • 19.9k
0 votes
0 answers
18 views

Auto-generate .pxd file with pyrobuf for faster calls in cython function

Context I would like to speedup a cython function where I read an osm.pbf file via pyrosm. In this library, the file is read via pyrobuf prototypes: pyrobuf generates a .c file with the relevant ...
Silmathoron's user avatar
  • 1,781
0 votes
1 answer
64 views

Indexing Python object not allowed without gil?

from cython.parallel import prange @cython.boundscheck(False) # Deactivate bounds checking @cython.wraparound(False) # Deactivate negative indexing. cpdef int find_indices(int[::1] values, int[::1]...
Razor's user avatar
  • 3
0 votes
0 answers
29 views

How to compile vector from cpp in cython?

I try to use vector data type in cython. cy_test.pyx from libcpp.vector cimport vector setup.py from distutils.core import setup from Cython.Build import cythonize setup(name="cy_test", ...
zchmielewska's user avatar
0 votes
1 answer
44 views

How do I take a subvector of a vector in Cython?

If I have a vector of a generic type (say cdef vector[string] a = [b'a', b'b', b'c']), how do I get a subvector from it? a[:2] converts it to a Python list and incurs an overhead, while the standard C+...
Kris's user avatar
  • 177
0 votes
0 answers
91 views

Trying to install PyRFC on a Linux server raises a Cython error

I have three Linux servers, supposed to be the same. On the first two servers, I managed to install PyRFC, but on the third I got the following error: Using cached pyrfc-2.8.2.tar.gz (284 kB) ...
zur_manny's user avatar

1
2 3 4 5
105