Calmcode - numba: conclusion

Conclusion

1 2 3 4 5 6

Here's the monte carlo example from the video.

import random

@nb.njit()
def monte_carlo_pi_fast(nsamples):
    acc = 0
    for i in range(nsamples):
        x = random.random()
        y = random.random()
        if (x ** 2 + y ** 2) < 1.0:
            acc += 1
    return 4.0 * acc / nsamples

For more information on supported types, see the docs.