[SciPy-user] callbacks in weave
Fernando Perez
fperez at colorado.edu
Mon May 5 19:03:33 EDT 2003
Hi all,
I wonder if it's possible to call-back into python from weave-inlined code
snippets. The included tutorial makes a passing mention of callable objects,
but with no details. I tried the code below but failed to make much progress.
Any help would be greatly appreciated. (For reference, I'm using a fairly
recent CVS snapshot, from a week or two ago).
Thanks in advance,
Cheers,
f.
# Code snippet below:
from weave import inline
def foo(x,y):
print "In Python's foo:"
print 'x',x
print 'y',y
def cfoo(x,y):
code = """
printf("Attemtping to call back foo() from C...\\n");
foo(x,y);
printf("Done.\\n");
"""
inline(code,"foo x y".split() )
x=99
y="Hello"
print "Pure python..."
foo(x,y)
print "Via weave..."
cfoo(x,y)
More information about the SciPy-User
mailing list