import numpy
import time
from Instant import inline_with_numpy
c_code = """
void ccos(int n1, double* x, int n2, double* y){
for (int i=0; i<n1; i++) {
y[i] = cos(x[i]);
}
}
"""
ccos = inline_with_numpy(c_code, arrays = [['n1', 'x'], ['n2', 'y']])
a = numpy.arange(10000000.0);
b = numpy.zeros(10000000)
t1 = time.time()
ccos (a,b)
t2 = time.time()
print 'With Instant:',t2-t1,'seconds'
t1 = time.time()
c = numpy.cos(a)
t2 = time.time()
print 'Med numpy: ',t2-t1,'seconds'
difference = max(c- b)
print "The difference between the sums computed by numpy and instant is " + str(difference)
syntax highlighted by Code2HTML, v. 0.9.1