Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numba
- import timeit
- @numba.jit
- def work():
- """
- This function is optimized by numba.
- """
- a = 0
- while a <= 1000000000:
- a += 1
- # to be sure, that this function is really called
- return 42
- if __name__ == '__main__':
- print("Compiled")
- print("Testing if function is working", end=" ")
- if work() == 42:
- print("[ OK ]")
- else:
- print("[ FAIL ]")
- jit_run = timeit.timeit(work)
- print('The jitted version took {:.0f} ms'.format(jit_run * 1000))
- print("Ended")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement