Differences between revisions 2 and 12 (spanning 10 versions)
Revision 2 as of 2002-07-15 17:48:59
Size: 1294
Editor: 66-106-86-210
Comment:
Revision 12 as of 2018-03-06 21:02:12
Size: 917
Editor: WimLavrijsen
Comment: Updated weave link. Note that all links in the 2nd paragraph are dead, too as the AsynCluster package itself seems to be.
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
weave The weave package allows the inclusion of C/C++ within Python code. It is part of the larger SciPy package (http://www.scipy.org), but is also available as a stand alone package (https://pypi.python.org/pypi/weave) so that more people can try it out.
Line 3: Line 3:
http://www.scipy.org/site_content/weave

The weave package allows the inclusion of C/C++ within Python code. It is part of the larger SciPy package (http://www.scipy.org), but is also available as a stand alone package (http://scipy.org/site_content/weave) so that more people can try it out.

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 an 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 speed-up over algorithms written in pure Python (However, it is also possible to slow things down...). 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.
The GPL'd [[http://foss.eepatents.com/trac/AsynCluster/wiki|AsynCluster]] project contains a package ''svpmc'', which has a module [[http://foss.tellectual.com/trac/AsynCluster/browser/projects/AsynCluster/trunk/svpmc/weave.py|svpmc.weave]]. The ''Weaver'' class in that module provides a convenient API for running C/C++ code with ''weave.inline''. See the [[http://foss.tellectual.com/trac/AsynCluster/browser/projects/AsynCluster/trunk/svpmc/sample.py|svpmc.sample]] module and its companion [[http://foss.tellectual.com/trac/AsynCluster/browser/projects/AsynCluster/trunk/svpmc/sample.c|C code file]] for an example of usage.
----
CategoryPythonInScience

The weave package allows the inclusion of C/C++ within Python code. It is part of the larger SciPy package (http://www.scipy.org), but is also available as a stand alone package (https://pypi.python.org/pypi/weave) so that more people can try it out.

The GPL'd AsynCluster project contains a package svpmc, which has a module svpmc.weave. The Weaver class in that module provides a convenient API for running C/C++ code with weave.inline. See the svpmc.sample module and its companion C code file for an example of usage.


CategoryPythonInScience

weave (last edited 2018-03-06 21:02:12 by WimLavrijsen)

Unable to edit the page? See the FrontPage for instructions.