aesara
aesara copied to clipboard
Consider turning on bounds checking by default for Numba compiled code
As a follow-up to the conversation in #1081, we should consider turning on bounds checking by default. One requirement is that NUMBA_BOUNDSCHECK
be honored.
Is NUMBA_BOUNDSCHECK set to False by default?
Is NUMBA_BOUNDSCHECK set to False by default?
Essentially.
Then we can't turn checks by default. Or did you mean something else?
Then we can't turn checks by default. Or did you mean something else?
We can turn bounds checking on by default in a "localized" way using the njit
decorator, but we also need to honor the NUMBA_BOUNDSCHECK
setting when/if it's set by the user.
I didn't really expect this behavior myself until I read the docs some time ago, but the environment variable overrides the keyword argument:
%env NUMBA_BOUNDSCHECK=0
import numpy as np
import numba
@numba.njit(boundscheck=True)
def foo(x):
return x[3]
foo(np.ones(2)) # No exception but undefined output
So I think we can just set the boundscheck
argument to whatever we think is a appropriate default in that function.