# cython: language_level = 3 import time import random from libc cimport math from libc.stdlib cimport calloc, free cdef main(): cdef double *a cdef double b cdef double c cdef double d cdef int i a = calloc(5000000, sizeof(double)) if a == NULL: raise SystemExit('calloc failed') try: random.seed(time.time()) t1=time.time() for i in range(5000000): b=random.random() if b>0.5: c=math.pow(b,1.546) else: c=math.pow(b,0.434232) d=math.cos(c+i) a[i]=math.atan(d) t2=time.time() print(t2-t1) finally: free(a) main()