C API from Extension Module in Python | Set 2
Prerequisite: C API from Extension Module in Python | Set 1
Let’s see an example of a new extension module that loads and uses these API functions that we build up in the previous article.
Code #1 :
Code #2 : Module initialization function
Now to compile this new module, one need not bother about how to link against any of the libraries or code from the other module. One can just simply use
work.py file as shown below.
Code #3 :
After performing all this task, this new extension function works perfectly with the C API functions defined in the other module.
Code #4 : Using CPI API functions defined in the other module
Point_1 : 2.000000 3.000000
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course