CoCalc Public Filesnumba.htmlOpen with one click!
Authors: harald @schil.ly, Testing CoCalc, Harald Schilly, Harald Schilly, HaraldTest SchillyTest, ℏal Snyder, William A. Stein
Views : 82
Description: Jupyter html version of numba.ipynb
Compute Environment: Ubuntu 18.04 (Deprecated)
numba
In [1]:
from numba import jit, int64
In [2]:
def f1(x, y):
    o = 0
    for i in range(x):
        for j in range(i, y, 2):
            if (i + j) % 13 != 0:
                o += i - j
    return o
In [3]:
f1(1000, 1000)
Out[3]:
-76923768
In [4]:
%timeit f1(1000, 1000)
10 loops, best of 3: 43.1 ms per loop
In [5]:
@jit(int64(int64, int64), nopython=False)
def f2(x, y):
    o = 0
    for i in range(x):
        for j in range(i, y, 2):
            if (i + j) % 13 != 0:
                o += i - j
    return o
In [6]:
f2(1000, 1000)
Out[6]:
-76923768
In [7]:
%timeit f2(1000, 1000)
1000 loops, best of 3: 527 µs per loop
In [ ]: