import time


start = time.time()


mylist = (x for x in range(1000)) #生成器不占内存


print(type(mylist))


for i in mylist:
    print(i)
    
end = time.time()
a1 = end - start


start = time.time()


mylist = [x for x in range(1000)] #生成器不占内存


print(type(mylist))


for i in mylist:
    print(i)
    
end = time.time()

a2 = end - start
a672d4fca3affcde36c23ffbc4d39080cd10c319
<mask token>

<mask token>
print(type(mylist))
for i in mylist:
    print(i)
<mask token>
print(type(mylist))
for i in mylist:
    print(i)
<mask token>

<mask token>
start = time.time()
mylist = (x for x in range(1000))
print(type(mylist))
for i in mylist:
    print(i)
end = time.time()
a1 = end - start
start = time.time()
mylist = [x for x in range(1000)]
print(type(mylist))
for i in mylist:
    print(i)
end = time.time()
a2 = end - start

import time
start = time.time()
mylist = (x for x in range(1000))
print(type(mylist))
for i in mylist:
    print(i)
end = time.time()
a1 = end - start
start = time.time()
mylist = [x for x in range(1000)]
print(type(mylist))
for i in mylist:
    print(i)
end = time.time()
a2 = end - start

import time


start = time.time()


mylist = (x for x in range(1000)) #生成器不占内存


print(type(mylist))


for i in mylist:
    print(i)
    
end = time.time()
a1 = end - start


start = time.time()


mylist = [x for x in range(1000)] #生成器不占内存


print(type(mylist))


for i in mylist:
    print(i)
    
end = time.time()

a2 = end - start