[SciPy-dev] rough cut at accelerated function class

eric eric at scipy.org
Thu Feb 14 03:27:19 CST 2002

Hey Pat,

proto.py is a rough cut of the accelerated function class.  Look at test2() to
see how it can work with weave.inline to build a C extension that calls a Python
function which has been compiled to C (Who's on first...?).  The extension
module it builds for a compiled function provides both by reference and by value
functions for the underlying C function so that both C and Fortran can use it
for callbacks.  Currently the fortran version (by reference) calls the by value
version.  I think we should inject the same code into each so that Fortran
callbacks are not slower the C callbacks.  We'll do this once we've refactored
the code a little to make it easier.

All callback functions are accesible through the Python object, so Pearu doesn't
need to do anything besides call a Python method on the object to get a pointer
to the accelerated (pure C) function.  This means no C header or source file
dependencies, etc.

The speed up for an array reduction using a simple function like:

   def my_add(a,b):
       return a + b

is a factor of 17-20 on my machine between using the C callback routine compared
to a Python callback.

I've made some changes to bytecodecompiler.py.  I'm sure you have too, so we'll
need to merge them.

The latest CVS of weave is needed for this code to work.

There is some code overlap between weave's type handling system and
bytecodecompiler's.  They need to be merged pretty soon here.

Quite a bit of work remains, but it is definitely taking shape.

Things not implemented:
    caching to disk
    most of the calling machinery for calls in Python doesn't exist.
    tons of re-factoring and cleanup needed.

see ya,

Eric Jones <eric at enthought.com>
Enthought, Inc. [www.enthought.com and www.scipy.org]
(512) 536-1057

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bytecodecompiler.py
Url: http://projects.scipy.org/pipermail/scipy-dev/attachments/20020214/678306bb/attachment.pl 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: proto.py
Url: http://projects.scipy.org/pipermail/scipy-dev/attachments/20020214/678306bb/attachment-0001.pl 

More information about the Scipy-dev mailing list