I intend to make a very large list which I need to append every element into it.
But I find it takes long, and when destructing it still takes long nearly as much as appending.
I know append maybe takes time, but why destruct still takes time as much as append in list?
Or i.e. what is the internal structure like in list? Something like linked list in cpp? And when I append elements into it, the actual memory is not contiguous so it takes long?
a = []
for i in range(0, 100000000):
a.append(i)
print('end')
A simple example is like as above. It take time before and after print till the program ends. Is there any method in speeding up both parts?
And I have another two tests like
b = [i for i in range(0, 100000000)]
print('end2')
c = [100000000] * 100000000
print('end3')
It turns out c is much more quickly then a and b. So is it an efficient way in initializing the list with an enough size?