Download this file
32 lines (27 with data), 651 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 | #!/usr/bin/env python
from weave import inline
def foo(x,y):
print "In Python's foo:"
print 'x',x
print 'y',y
return x
def cfoo(x,y):
code = """
printf("Attemtping to call back foo() from C...\\n");
py::tuple foo_args(2);
py::object z; // This will hold the return value of foo()
foo_args[0] = x;
foo_args[1] = y;
z = foo.call(foo_args);
printf("Exiting C code.\\n");
return_val = z;
"""
return inline(code,"foo x y".split() )
x=99
y="Hello"
print "Pure python..."
z=foo(x,y)
print "foo returned:",z
print "\nVia weave..."
z=cfoo(x,y)
print "cfoo returned:",z
|
×
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.