소스 뷰어
%%time

import numpy as np 
from matplotlib import pyplot as plt

def f(y, x):
    return (x == y)*255
pass

img = np.fromfunction( f, (1_000, 1_000) )

plt.imshow( img, cmap='gray' ) 
plt.show()
No description has been provided for this image
Wall time: 609 ms
%%time

import numpy as np 
from matplotlib import pyplot as plt

shape=(1_000, 1_000) 
img = np.empty( shape=shape )

for y in range( shape[0] ) :
    for x in range( shape[1] ) :        
        if y == x :
            img[ y, x ] = 255 
        else :
            img[ y, x ] = 0
        pass
    pass
pass

plt.imshow( img, cmap='gray' ) 
plt.show()
No description has been provided for this image
Wall time: 1.24 s