ANN: weave -- inline C/C++ in Python
Travis N. Vaught
travis at enthought.com
Tue Jan 15 17:38:53 CET 2002
weave is a new package for inlining C/C++ within Python. Among other
following is possible:
>>> import weave
>>> a = 1
It also works for useful examples...
Weave is distributed as source using .zip and .tar.gz files (inlcuding a
setup.py), or as a windows click-install executable. It succesfully passes
its test suite on W2K (MSVC, gcc-2.95.2), RH 7.1 (gcc-2.96), Solaris
(gcc-2.95.1), and Debian (gcc-???). It reportedly fails on Mandrake. Please
try it out and report success/failure on your architecture.
post to: scipy-dev at scipy.org
>From the Overview:
Including C/C++ code within Python offers both another level of
optimization to those who need it, and an easy way to modify and extend
supported extension libraries such as wxPython and hopefully VTK soon.
Inlining C/C++ code within Python generally results in speed ups of 1.5x to
30x over algorithms written in pure Python or Numeric. Generally algorithms
that require a large number of calls to the Python API don't benefit as much
from the conversion to C/C++ as algorithms that have inner loops completely
convertable to C.
There are three basic ways to use weave. The weave.inline() function
executes C code directly within Python, and weave.blitz() translates Python
Numeric expression to C++ for fast execution. blitz() was the original
functionality for which weave was built. For those interested in building
extension libraries, the ext_tools module provides classes for building
extension modules within Python.
More information about the Python-list