NumPy C-API#

Beware of the man who won’t be bothered with details.
William Feather, Sr.
The truth is out there.
Chris Carter, The X Files

NumPy provides a C-API to enable users to extend the system and getaccess to the array object for use in other routines. The best way totruly understand the C-API is to read the source code. If you areunfamiliar with (C) source code, however, this can be a dauntingexperience at first. Be assured that the task becomes easier withpractice, and you may be surprised at how simple the C-code can be tounderstand. Even if you don’t think you can write C-code from scratch,it is much easier to understand and modify already-written source codethan create itde novo.

Python extensions are especially straightforward to understand becausethey all have a very similar structure. Admittedly, NumPy is not atrivial extension to Python, and may take a little more snooping tograsp. This is especially true because of the code-generationtechniques, which simplify maintenance of very similar code, but canmake the code a little less readable to beginners. Still, with alittle persistence, the code can be opened to your understanding. Itis my hope, that this guide to the C-API can assist in the process ofbecoming familiar with the compiled-level work that can be done withNumPy in order to squeeze that last bit of necessary speed out of yourcode.