I need to replace, in a large number of Python files with many function definitions, all occurrences of
def some_func(foo, bar):
with
@jit(parallel=True)
def some_func(foo, bar):
with whatever level of indentation def some_func(foo, bar)
has.
Example: I want to replace
def some_func_1(foo, bar):
def some_func_2(foo, bar):
def some_func_3(foo, bar):
def some_func_4(foo, bar):
with
@jit(parallel=True)
def some_func_1(foo, bar):
@jit(parallel=True)
def some_func_2(foo, bar):
@jit(parallel=True)
def some_func_3(foo, bar):
@jit(parallel=True)
def some_func_4(foo, bar):
Motivation: I want to "brute-force accelerate/parallelize" a FDTD simulation package without having to rewrite the entire codebase by making use of numba
's automatic parallelization with @jit
.
PS.: Any comment/critique of this naive approach of (ab)using @jit
is also welcome (e.g. if this wouldn't work at all)!
External links referenced by this document: