timeit.timeit(
    'pygame.surfarray.blit_array(screen, pixels);pygame.display.flip()',
    setup=
    'import pygame;import numpy as np;size=(1920,1080);screen=pygame.display.set_mode(size);pixels=np.random.randint(np.iinfo(np.uint32).max,size=size).astype(np.uint32)'
    , number=20)
timeit.timeit(
    """
pygame.surfarray.blit_array(screen, pixels)
pygame.display.flip()
""",
    setup=
    """
import pygame
import numpy as np
size=(1920,1080)
screen=pygame.display.set_mode(size)
pixels=np.random.randint(np.iinfo(np.uint32).max,size=size).astype(np.uint32)
"""
    , number=20)
Setting Pixels Quickly