0
$\begingroup$

Numba offers JIT for Python. In its documentation it says "One objective of Numba is having a seamless integration with NumPy."

So why including some of the simplest features from numpy isn't possible:

import numpy as np
from numba import *

@jit(nopython=True)
def testfun(x):
     y = np.size(x)
     return y

x=np.array([1 ,2, 3],dtype=float)
testfun(x)

When I run this code, I get the error "Unknown attribute 'size' of type Module."

Numba understands calls to NumPy ufuncs. I assume simple numpy functions such as size, shape, sum, reshape, etc are ufuncs.

$\endgroup$
1
$\begingroup$

Not sure why it is not supported, but this works:

import numpy as np
from numba import *

@jit(nopython=True)
def testfun(x):
     y = x.size
     return y

x=np.array([1 ,2, 3],dtype=float)
testfun(x)

You might want to have a look at the Supported NumPy features on their web-site.

| cite | improve this answer | |
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.