python run faster code example
Example 1: optimized for loop in python
#Squaring all numbers in a list
l=[43,23,51,76,98]
map(lambda num:num**2,l)
Example 2: type python fast
def f(double x):
return x ** 2 - x
def integrate_f(double a, double b, int N):
cdef int i
cdef double s, dx
s = 0
dx = (b - a) / N
for i in range(N):
s += f(a + i * dx)
return s * dx