'How to draw each pixel faster in pygame?

hi i'm trying to create a program in pygame with a fading effect, of the rgb squares/ wheels that are in drawing softwares, i managed to find a way to calculate rgb values based on the x,y coordinates of the screen, but drawing each pixel takes a lot of time, i searched and didn't really understand how to do it with arrays or images so any advice would be great, also if there is anything other then pygame that could do the work let me know.

here is the part of the code

while True: if B < 255: B += 1

for y in range(SIDE + 1):
    for x in range(SIDE):
        r = y

        g = (x + 1) * y / SIDE      

        b = y * (B / SIDE)           
        b += (y - b) / SIDE * x     

        
        pygame.Surface.set_at(screen, (x, y), (r, round(g), round(b)))
pygame.display.update() 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source