install numba in osx yosemite with brew

brew tap homebrew/versions
brew install --disable-assertions --rtti llvm33
LLVM_CONFIG_PATH=/usr/local/Cellar/llvm33/3.3_1/bin/llvm-config-3.3 pip install llvmpy
pip install numba
from numba import jit
from numpy import random
# jit decorator tells Numba to compile this function.
# The argument types will be inferred by Numba when function is called.
@jit
def sum2d(arr):
    M, N = arr.shape
    result = 0.0
    for i in range(M):
        for j in range(N):
            result += arr[i,j]
    return result

def sum2dpy(arr):
    M, N = arr.shape
    result = 0.0
    for i in range(M):
        for j in range(N):
            result += arr[i,j]
    return result

a = random.randint(low=-1e8, high=1e8, size=1e4).reshape(1e2,1e2)
%timeit sum2d(a)
%timeit sum2dpy(a)
%timeit a.sum()

2 thoughts on “install numba in osx yosemite with brew”

Leave a Reply to Talgat Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>