[SciPy-dev] Accelerated modules

eric eric at scipy.org
Mon Feb 11 23:02:20 EST 2002


Hey Pat,

I like the name accelerate.

> I think the model we want to shoot for with weave accelerated
> modules and functions is something like in
>
> # This is foobar.py
>
> def f(x):
>     < some thing >
>
> def g(x,y):
>     < some other thing >
>
> class foo:
>     def __init__(self):
>          ...
>     def solver(self,x):
>          ....
>
> try:
>      # Pull in accelerated ones if they exist
>      from foobar.accelerated import *
> except:
>      import weave
>      f = weave.accelerate(f)
>      g = weave.accelerate(g)
>      foo.solver = weave.accelerate(foo.solver)

I don't think we need the try/except though.  weave.accelerate(f) should
check the on disk "catalog" for previously compiled versions of f.  If they
exist, it should load them.  Actually, the "accelerated object" returned by
weave.accelerate should handle all this.  Things could be loaded from the on
disk catalog during __init__, or the first time __call__ is accessed.  So,
the  above would become:

# This is foobar.py

def f(x):
    < some thing >

def g(x,y):
    < some other thing >

class foo:
    def __init__(self):
         ...
    def solver(self,x):
         ....

# acceleration methods
import weave
f = weave.accelerate(f)
g = weave.accelerate(g)
foo.solver = weave.accelerate(foo.solver)


eric






More information about the SciPy-Dev mailing list