Questions tagged [cythonize]

Use this tag for questions about the compilation of python extension modules based on cython using "cythonize". Use the more generic [cython] tag if the question isn't about the actual compilation process.

The cythonize function can be imported from Cython.Build and is used to compile extensions for python. It is responsible for compiling the .pyx (cython files) to .c files.

The cython "Compilation" documentation contains several examples how to include cythonize in the build process for python modules.

342 questions
0
votes
1 answer

How to debug a cython code before compiling?

I recently came across sentdex tutorial for cython. While trying out his tutorial codes the thing I noticed is how we will debug our cython code before compiling it. The original code we can debug by running it example_original.py in our …
Eka
  • 14,170
  • 38
  • 128
  • 212
0
votes
0 answers

Cython: assigning INFINITY or numpy.inf to a typed variable results to 0

I wish to cdef an INFINITY constant in a file named constant.pxd so that I can cimport it elsewhere. Assume in constant.pxd we have: import numpy as np cimport numpy as np from libc cimport math ctypedef np.float32_t dtype_t cdef dtype_t INF =…
Jiayao Zhang
  • 170
  • 1
  • 9
0
votes
0 answers

sklearn.mixture After Cython Does Not Become Faster

I am a Python newbie and I have to do some simple work with it. I use sklearn.mixture methods to process the data, though, it takes too much time. I have read somewhere here and have decided to cythonize these functions. I have done python…
Donz
  • 1,389
  • 1
  • 13
  • 21
0
votes
1 answer

subclassing cython class: pxd file not found when 'cimport'ing

I have just stumbled across some strange behaviour in cython and I am hoping someone will be able to enlighten me. I have two packages A and B, both built using distutils because I have several cython classes (many of which wrap c++ classes). In…
stefano
  • 359
  • 1
  • 3
  • 13
0
votes
0 answers

How to get SFML's error message to Cython?

I'm trying to wrap SFML's error stream to retrieve last error message into Python space. Here is how SFML declares it's error stream (see source): namespace sf { std::ostream& err(); } SFML says, that you can redirect the above stream into your…
HankMoody
  • 3,077
  • 1
  • 17
  • 38
0
votes
1 answer

Making my cython code more efficient

I've written a python program which I try to cythonize. Is there any suggestion how to make the for-loop more efficient, as this is taking 99% of the time? This is the for-loop: for i in range(l): b1[i] = np.nanargmin(locator[i,:]) #…
Kristin
  • 19
  • 2
0
votes
0 answers

Cythonize python dictionary object

I am using cython to improve the performance of the python functions. Basically i can improve performance only in dictionary operations. So i was trying to search for any dictionary written in c, I found that cython itself contains a .pxd file which…
srujith poondla
  • 171
  • 1
  • 12
0
votes
0 answers

Cython: ImportError: DLL load failed: %1 is not a valid Win32 application

I compiled my Python code with Cython and got a .pyd file. I want to import it so I was advised to put it in my PYTHONPATH. Here it is : In [1]: import sys In [2]: sys.path Out[2]: ['', …
Loïc Poncin
  • 511
  • 1
  • 11
  • 30
0
votes
1 answer

Anaconda cython-built module is looking for wrong GLIBCXX

Let me explain the situation. I compiled a c++ library using system g++ (under linux). Then built a cython module which calls a function in the pre-compiled library. Building the cython module was done under an anaconada venv (but no g++ installed…
Hoseung Choi
  • 1,017
  • 2
  • 12
  • 20
0
votes
0 answers

How to properly free a pointer-to-pointer in Cython?

I would like to free memory allocated a variable that is a pointer-to-pointer (or a "double pointer" -- not to be confused with pointer to a double datatype.) Suppose the pointer-to-pointer is **ptr and (for simplicity) it is a 10x10 array of…
Pavithran Iyer
  • 402
  • 5
  • 14
0
votes
1 answer

How to optimize this cython code? I found only 3 percent increase in speed

This is my fun.pyx file cimport cython @cython.boundscheck(False) cdef long long int extr(): cdef long long int i=0; while i<=20000000000: i=i+1 return i def fn(): return extr() This is my test.py file from fun import…
user6359857
0
votes
2 answers

Error when wrapping helloworld in c++ into python with cython

I have the following files: helloworld.cpp which contains #include #include void Helloworld(){ …
SomeRandomPhysicist
  • 1,531
  • 4
  • 19
  • 42
0
votes
0 answers

Cython pxd "cimport XXX as YYY" leads to "YYY.pxd not found", even though "cimport XXX" works

The title almost explains everything. I'm trying to cimport a module with cimport myMinExPkg.someModule.base as someModuleBase and then using the "someModuleBase" alias like someModuleBase.BaseClass but this results in an…
oli
  • 659
  • 1
  • 6
  • 18
0
votes
1 answer

Error in importing PIRT( Python Image Registration Toolkit) in python

So, i have install the PIRT package for image registration. But i am not able to import it in my python. It is showing some error : >>> import pirt Traceback (most recent call last): File "", line 1, in File…
decipher
  • 498
  • 2
  • 4
  • 16
0
votes
1 answer

Problems wth building Python Image Registration Toolkit

I'm having trouble building PIRT (Python Image Registration Toolkit library). I have downloaded from bitbucket using mercurial (hg clone https://bitbucket.org/almarklein/pirt). But when I try to build it using python setup.py I get the following…
decipher
  • 498
  • 2
  • 4
  • 16
1 2 3
22
23