User guide
NumPy User Guide, Release 1.9.0
– around a long time
– multiple scripting language support
– C++ support
– Good for wrapping large (many functions) existing C libraries
• Minuses:
– generates lots of code between Python and the C code
– can cause performance problems that are nearly impossible to optimize out
– interface files can be hard to write
– doesn’t necessarily avoid reference counting issues or needing to know API’s
7. scipy.weave
• Plusses:
– can turn many numpy expressions into C code
– dynamic compiling and loading of generated C code
– can embed pure C code in Python module and have weave extract, generate interfaces and compile, etc.
• Minuses:
– Future very uncertain: it’s the only part of Scipy not ported to Python 3 and is effectively deprecated in
favor of Cython.
8. Psyco
• Plusses:
– Turns pure python into efficient machine code through jit-like optimizations
– very fast when it optimizes well
• Minuses:
– Only on intel (windows?)
– Doesn’t do much for numpy?
4.5 Interfacing to Fortran:
The clear choice to wrap Fortran code is f2py.
Pyfort is an older alternative, but not supported any longer. Fwrap is a newer project that looked promising but isn’t
being developed any longer.
4.6 Interfacing to C++:
1. Cython
2. CXX
3. Boost.python
4. SWIG
50 Chapter 4. Miscellaneous