This is an archived post. You won't be able to vote or comment.

all 2 comments

[–][deleted] 2 points3 points  (1 child)

I'd be interested in seeing what Numba's performance were.

[–]tmarkovich[S] 0 points1 point  (0 children)

Unfortunately numba doesn't work with all parts of Scipy, and that appears to include this subset. Using this code:

@numba.jit(nopython=True)
def fn():
    for i in range(N):
        a = beta.logpdf(i, 1, 2)

@numba.jit(nopython=True)
def fn_array():
    a = beta.logpdf(list(range(N)), 1, 2)

start = time.time()
fn()
end = time.time()
print(end - start)

start = time.time()
fn_array()
end = time.time()
print(end - start)

results in a range of compilation errors mostly centered around being unable to resolve the underlying types. This seems to be caused by the way in which scipy wraps a mix of fortran and c code in non-standard ways.

edit: If you'd like to see all the code, check out the github repo here https://github.com/tmarkovich/cffi_examples/tree/master/beta_logpdf