Hi,
I run the sample code from the site as:
@jit
def sum2(two_dimensional_array):
result = 0.0
J, I = two_dimensional_array.shape
for i in range(J):
for j in range(I):
result += two_dimensional_array[i,j]
return result
When I add the try-catch error handling as:
@jit
def sum1(two_dimensional_array):
result = 0.0
try:
J, I = two_dimensional_array.shape
for i in range(J):
for j in range(I):
result += two_dimensional_array[i,j]
except Exception:
pass
return result
I got an error as:
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\dispatcher.py", line 287, in _compile_for_args
return self.compile(tuple(argtypes))
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\dispatcher.py", line 555, in compile
cres = self._compiler.compile(args, return_type)
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\dispatcher.py", line 81, in compile
flags=flags, locals=self.locals)
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\compiler.py", line 699, in compile_extra
return pipeline.compile_extra(func)
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\compiler.py", line 352, in compile_extra
return self._compile_bytecode()
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\compiler.py", line 660, in _compile_bytecode
return self._compile_core()
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\compiler.py", line 647, in _compile_core
res = pm.run(self.status)
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\compiler.py", line 238, in run
raise patched_exception
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\compiler.py", line 230, in run
stage()
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\compiler.py", line 366, in stage_analyze_bytecode
func_ir = translate_stage(self.func_id, self.bc)
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\compiler.py", line 762, in translate_stage
return interp.interpret(bytecode)
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\interpreter.py", line 91, in interpret
self.cfa.run()
File "C:\Users\Ernest\AppData\Local\Continuum\lib\site-packages\numba\controlflow.py", line 515, in run
assert not inst.is_jump, inst
AssertionError: Failed at object (analyzing bytecode)
SETUP_EXCEPT(arg=85, lineno=14)
Any help?
Thank you!
Try-catch is not supported.
In this case, we can't use it at this time. Very bad for Python programmers!
Exceptions can still be raised and they get propagated all the way up. You can still catch them in the non-jit function.
Our current focus is in high-performance numeric code, such code rarely needs to catch exceptions. On the other hand, the catch semantic can affect the optimizations, disabling auto-vectorization and other aggressive loop transformation.
Most helpful comment
Try-catch is not supported.