Skip to content
Advertisement

Tag: cython

Is there a better way to use cython when looking to speed up Python?

I have a large numpy array with the following structure: I’m using cython to try and speed up the processing as much as possible. The argument dataset in the code below is the above array. However, when running the above code with and without cython I get the following times: without cython: 0:00:00.945872 with cython: 0:00:00.561925 Any ideas how I

Do I need to use `nogil` in Cython

I have some Cython code that I’d like to run as quickly as possible. Do I need to release the GIL in order to do this? Let’s suppose my code is similar to this: I get a whole load of error messages from the np.zeros_like line similar to: Do I need to find a way of calling np.zeros_like without the

PyCharm CE does not recognize .pyx files

PyCharm Community Edition (CE) does not recognize few Cython files as shown in the picture below (with PyCharm red mark under the file name). Could you please advise me on what can I do ? Answer The PyCharm Community Edition does not support Cython. You should get PyCharm Professional Edition to get that feature.

Cython class AttributeError

I have started to experiment with Cython and ran into the following problem. Consider the following class representing a vertex in the 3D space: Now I try to create an object from the Python console: which works fine. However, when I’m trying to access the class attributes, I’m getting an AttributeError: Any ideas why this could happen? Answer By default

Translating python function with boolean indexing within loop to cython

Below I’ll write a function in pure python that I want to Cythonize. Suppose that I know how to Cythonize the function do_stuff. The actual do_stuff function I’m interested in is more complicated than the one above but I thought I’d provide an example. The real do_stuff function computes determinants and takes inverses, in addition to matrix multiplication. My main

Advertisement