Extending Python with C or C++

sturlamolden sturlamolden at yahoo.no
Tue Jan 6 17:03:41 CET 2009


On Jan 5, 9:06 pm, Ryan <heni... at yahoo.com> wrote:

> I've been using Python for many years now. It's a wonderful language
> that I enjoy using everyday. I'm now interested in getting to know
> more about the guts (C/C++) and extending it. But, extending python
> still seems like a black art to me.


There are several alternatives to using the Python C API by hand,
depending on
your particular need. It will save you a lot of greif:

Pyrex: Python-like language for creating extension modules.

*Cython: clone of Pyrex

*ctypes: call DLLs from python

comtypes: call COM DLLs from Python

*f2py: generate wrappers for Fortran or C libraries. Knowledge of
Fortran required.

pywin32: use or implement ActiveX objects with Python

*scipy.weave: inline C++ code in Python

Swig: generate wrappers for C libraries (some C++ support)

CXX: C++ wrapper for the Python C API

Boost.Python: C++ wrapper for the Python C API

SIP: generate wrappers for C++ libraries

(* Works easily with NumPy arrays.)









More information about the Python-list mailing list