Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ANN: weave -- inline C/C++ in Python

0 views
Skip to first unread message

Travis N. Vaught

unread,
Jan 15, 2002, 11:38:53 AM1/15/02
to
weave is a new package for inlining C/C++ within Python. Among other
things, the
following is possible:

>>> import weave
>>> a = 1
>>> weave.inline('printf("%d\\n",a);',['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
(mostly)
(gcc-2.95.1), and Debian (gcc-???). It reportedly fails on Mandrake. Please
try it out and report success/failure on your architecture.

Web Site:

http://www.scipy.org/site_content/weave


Mail list:

http://scipy.net/mailman/listinfo/scipy-dev

post to: scip...@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.


0 new messages