Python 3: Most efficient way to create a [func(i) for i in range(N)] list comprehension
- by mejiwa
Say I have a function func(i) that creates an object for an integer i, and N is some nonnegative integer. Then what's the fastest way to create a list (not a range) equal to this list
mylist = [func(i) for i in range(N)]
without resorting to advanced methods like creating a function in C? My main concern with the above list comprehension is that…