[SciPy-dev] Thoughts on weave improvements

Pat Miller pnmiller at pacbell.net
Mon Feb 11 22:03:30 CST 2002


eric wrote:

> Hey Pat,
> 
> This is a very rough outline of what I thought of in the airplane rides
> home. All "sketch" of a solution below has holes, but is a start at merging
> pycod and weave.  The basic concept is to create a new class or type that
> wraps a function.  When a class wrapper object is called from Python, it


----------------------------------------------------------
Comments on the interface....  I prefer a weave method
called accelerate rather than the mystifying COD,  This
way, we could add in bytecode optimization and function
inlining and clever bits like that through the same
interface.
----------------------------------------------------------
For individual functions, the interface might look like:

import weave

def f(a,b):  << some big hairy thing >>
f = weave.accelerate(f)

----------------------------------------------------------
I think we should allow users to specify signatures if
they want to...
----------------------------------------------------------
f = weave.accelerate(f,signatures=[[FloatType],[IntType]])

where signature is a suggested list of types to compile for.
If you wanted to allow other types it could be:

f = weave.accelerate(f,signatures=[[FloatType],[IntType],[None]])

where None indicates "Any type is OK".  The default for signatures
would be equivalent to [[None]], so is equivalent to Eric's scheme.
Having a None signature means that as a last resort, the system
will call the original code object which we can carefully squirrel
away.  This means never having to say you're sorry on a call!

The default implementation for weave.accelerate is

def accelerate(self,f, signatures=None):
   return f

on systems where we don't have a compiler.







More information about the Scipy-dev mailing list