User guide

NumPy User Guide, Release 1.9.0
Efficient
No dependencies on other tools
Minuses:
Lots of learning overhead:
*
need to learn basics of Python C API
*
need to learn basics of numpy C API
*
need to learn how to handle reference counting and love it.
Reference counting often difficult to get right.
*
getting it wrong leads to memory leaks, and worse, segfaults
API will change for Python 3.0!
2. Cython
Plusses:
avoid learning C API’s
no dealing with reference counting
can code in pseudo python and generate C code
can also interface to existing C code
should shield you from changes to Python C api
has become the de-facto standard within the scientific Python community
fast indexing support for arrays
Minuses:
Can write code in non-standard form which may become obsolete
Not as flexible as manual wrapping
4. ctypes
Plusses:
part of Python standard library
good for interfacing to existing sharable libraries, particularly Windows DLLs
avoids API/reference counting issues
good numpy support: arrays have all these in their ctypes attribute:
a.ctypes.data a.ctypes.get_strides
a.ctypes.data_as a.ctypes.shape
a.ctypes.get_as_parameter a.ctypes.shape_as
a.ctypes.get_data a.ctypes.strides
a.ctypes.get_shape a.ctypes.strides_as
Minuses:
can’t use for writing code to be turned into C extensions, only a wrapper tool.
5. SWIG (automatic wrapper generator)
Plusses:
4.4. Interfacing to C 49