Hope this is good place to  ask question about Cython as well. 
Following code of mine is taking 2.5 times more time than Native Python code:

%%cython
import numpy as np
a = np.array([])
def large_sum2(int num_range):
    np.append(a,[i for i in xrange(num_range)])
    return a.sum

%timeit large_sum2(100000)
10 loops, best of 3: 19 ms per loop

on the other side python takes much less time:

def large_sum(num_range):
    return sum([i for i in xrange(num_range)])

%timeit large_sum(100000)
100 loops, best of 3: 7 ms per loop
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to