Calling a C function from Python ================================ This tutorial shows how to create a C function and call it from Python. This case arises when we want to analyse the output of a C function using python modules such as Numpy or Matplotlib for rapid prototyping. For example, this approach can help you to debug low-level signal processing algorithms implemented in C. In this tutorial, I consider a simple case where we want to compute the cosine value for each element of a :code:`Numpy` array. Note that this computation can be performed using the Numpy function :code:`cos` directly, but for the sake of illustration, we will implement this function in pure C. Implement your C function ------------------------- First, we need to create a :code:`my_lib.c` file with a single function called :code:`my_cos`. The :code:`my_cos` function contains a for loop function that computes the cosine value for each element of the input array :code:`*in_array`. .. code :: c #include void my_cos(double *in_array, double *out_array, int size){ int i; for(i=0; i