Summary

In this chapter, we introduced you to yet another way of optimizing or integrating C/C++ code using the C-API provided by Python and NumPy. We explained the basic structure of the code and the additional boilerplate code, which a developer has to write in order to create an extension module. Afterwards, we created two functions that calculated the square of a number and mapped the square function from the math.h library to a Numpy Array. The intention here was to familiarize you with how to leverage numerical libraries written in C/C++ to create your own modules with a minimal rewriting of code. The scope for writing C code is much wider than what is described here; however, we hope that this chapter has given you the confidence to leverage ...

Get NumPy Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.