O'Reilly Open Source Convention
oreilly.comO'Reilly Network
Conferences International Safari: Books Online


Arrow Home
Arrow Registration
Arrow Speakers
Arrow Keynotes
Arrow Tutorials
Arrow Sessions
Arrow At-a-Glance
Arrow BOFs
Arrow Events
Arrow Exhibitors
Arrow Sponsors
Arrow Hotel/Travel
Arrow Venue Map
Arrow See & Do
Arrow Press
Arrow Mail List
Kids World


From the Frontiers of Research to the Heart of the Enterprise
O'Reilly Open Source Convention
Sheraton San Diego Hotel and Marina
July 22-26, 2002 -- San Diego, CA


Apache

Session

weave -- inlining C/C++ in Python
Eric Jones, Enthought
Patrick J. Miller, Lawrence Livermore National Laboratory

Track: Python
Date: Thursday, July 25
Time: 10:45am - 11:30am
Location: Marina IV

The weave package allows the inclusion of C/C++ within Python code. It is part of Enthought's SciPy.org project. Embedding C/C++ 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. Inlining C/C++ code within Python generally results in speed ups of 1.5x to 30x speed-up over algorithms written in pure Python, and computational algorithms based on Numeric arrays often see a factor of 100 or more. 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 convertible to C/C++.

There are three basic ways to use weave. The weave.inline() function executes C/C++ code directly within Python, and weave.blitz() translates Python Numeric expression to C++ for fast execution. For those interested in writing extension libraries, the ext_tools module provides classes for building extension modules within Python.

More recent work on weave has focused on compiling Python byte-code into C extension functions on the fly. Patrick Miller will discuss the project in this area.

Most of weave's functionality should work on Windows and Unix, although some of its functionality requires gcc or a similarly modern C++ compiler that handles templates well.

For more information on weave, please visit: http://www.scipy.org/site_content/weave



oreilly.com Home | O'Reilly Bookstores | How to Order | O'Reilly Contacts
International | About O'Reilly | Affiliated Companies | Privacy Policy


© 2001, O'Reilly Media, Inc.
conf-webmaster@oreilly.com