43acc97ab8
You can dynamically compile & execute C/C++ code within your Python scripts with weave. Short example of use: doc@mainframe:~> python2p3 Python 2p3 (#1, Nov 19 2003, 22:40:23) [GCC 2.95.3 20010315 (release) (NetBSD nb3)] on netbsd1 Type "help", "copyright", "credits" or "license" for more information. >>> import weave >>> weave.inline('puts("C/C++ is teh sux0r, so we put it inside Python scripts");') C/C++ is teh sux0r, so we put it inside Python scripts >>>
12 lines
784 B
Text
12 lines
784 B
Text
The weave package allows the inclusion of C/C++ within Python code. It is
|
|
part of the larger SciPy package, but is made available here as a stand
|
|
alone package 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.
|