Skip to content

Instantly share code, notes, and snippets.

@sergiolucero
Created February 10, 2022 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergiolucero/ad8ee5a3b0f7078170dab76dbac2d145 to your computer and use it in GitHub Desktop.
Save sergiolucero/ad8ee5a3b0f7078170dab76dbac2d145 to your computer and use it in GitHub Desktop.
numba psums
from numba import jit
@jit(nopython=True)
def psum(p):
acc = 0
for i in range(1,1000000):
acc += pow(i, -p)
return acc
import time
t0=time.time()
ps = [psum(p) for p in range(2,20)]
print('DT:', round(time.time()-t0,2))
@sergiolucero
Copy link
Author

DT=0.7 vs 4.5 on data.quant.cl

@sergiolucero
Copy link
Author

even faster 2nd time around!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment