on-internet
← Community

Numba not speeding up python code looping over all pixels

Stack Overflow ·

I am trying to make a pixel-based simulation, and am having some performance issues. I thought I could use numbas JIT-compilation to speed it up, but when I run the code it runs ~14% slower. This is the code: @jit(nopython=True) def update(pixels): new_pixels = [1 for _ in range(grid_size[0]*grid_size[1])] for y in range(grid_size[1]): for x in range(grid_size[0]): pixel = pixels[x + y*grid_size[0]] u = pixels[x + (y-1)*grid_size[0]] if y-1 >= 0 else 0 d = pixels[x + (y+1)*grid_size[0]] if y+1 < grid_size[1] else 0 if pixel in [1, 4, 9]: # if pixel is air, smoke or steam if u == 2: # if up is

Comments

Sign in or sign up to comment and upvote.

No comments yet.