Why there is a significant difference in python3 in-line array initialization vs use of * operator?

Viewed 21

After multiple testing I have realized that

a = 1000
b = 2000
test = [ [ 0 for i in range(a) ] for j in range(b) ]

takes more time as compared to

a = 1000
b = 2000
test = [ [0] * a for i in range(b) ]

in python3. Anyone can explain why is that? Or am I missing something here?

0 Answers
Related