Skip to Content
NumPy Essentials
book

NumPy Essentials

by Jaidev Deshpande, Leo (Liang-Huan) Chin, Tanmay Dutta, Shane Holloway
April 2016
Beginner content levelBeginner
156 pages
3h 23m
English
Packt Publishing
Content preview from NumPy Essentials

The basic structure of an extension module

An extension module written in C will have the following parts:

  • A header segment, where you include all your external libraries and Python.h
  • An initialization segment, where you define the module name and the functions in your C module
  • A method structure array to define all the functions in your module
  • An implementation segment, where you define all the functions that you would like to expose

The header segment

Header snippets are quite standard, just like a normal C module. We need to include the Python.h header file to give our C code access to the internals of the C-API. This file is present in <path_to_python>/include. We will be using an array object in our example code, hence we have included the numpy/arrayobject.h ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

SciPy and NumPy

SciPy and NumPy

Eli Bressert
Python Distilled

Python Distilled

David M. Beazley

Publisher Resources

ISBN: 9781784393670Supplemental Content