Skip to content
Advertisement

Tag: cython

How to pass Python list to C function using Cython

I am using a Raspberry Pi to interface with custom hardware connected to the GPIO. The controlling software is written in Python, and the interface to the custom hardware is written in C, as it is a much faster C implementation. I now need to start calling my C functions from my Python, and have recently been learning how to

Force NumPy ndarray to take ownership of its memory in Cython

Following this answer to “Can I force a numpy ndarray to take ownership of its memory?” I attempted to use the Python C API function PyArray_ENABLEFLAGS through Cython’s NumPy wrapper and found it is not exposed. The following attempt to expose it manually (this is just a minimum example reproducing the failure) fails with a compile error: My question: Is

Getting started with cython on mac os

I wrote a simple program in python: Then I execute this: It was generated a file: main.c And then I tried this: And I have an error: How to compile python to c ? How to get started with cython with xcode on mac ? Answer You have to tell the gcc compiler where is the pyconfig.h file on your

Correct way to generate random numbers in Cython?

What is the most efficient and portable way to generate a random random in [0,1] in Cython? One approach is to use INT_MAX and rand() from the C library: Is it OK to use INT_MAX in this way? I noticed that it’s quite different from the constant you get from Python’s max int: yields: Which is the right “normalization” number

Advertisement