Calling a C Function in Python:

In this article, we will see calling C function using Python from the basics for Data Science.

First, we will write a simple function using C and hen generate the shred library of the file. Let the name of the file be function.c.

Calling a C Function in Python for Data Science - PST Analytics

Using ctypes (foreign function interface) library for calling a C function from Python:

The above compile statement will generate a shared library named libfun.so. We will observe how we can make use of it. Python has a library known as ctypes. So, by taking help of this library, it is possible to use C functions in Python. Suppose the file name is function.py.

Calling a C Function in Python for Data Science - PST Analytics

So, to learn more about it in python for data science, you can check this and this as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.