@@ -7,17 +7,19 @@ In a UNIX terminal, run:
77
88``` 
99time python list-append-loop.py 
10- ``` 
10+ 
1111real	0m11.381s 
1212user	0m10.553s 
1313sys		0m0.824s 
14+ ``` 
1415
1516``` 
1617time python list-comp.py 
17- ``` 
18+ 
1819real	0m4.228s 
1920user	0m3.428s 
2021sys		0m0.800s 
22+ ``` 
2123
2224
2325Here we see that the list comprehension was almost 3x as fast
@@ -31,24 +33,32 @@ numbers with the range() function, we can actually just cast the result
3133of the range() function to a list and get even faster speed than the
3234list comprehension. 
3335
36+ ``` 
37+ time python cast-list.py 
38+ 
39+ real	0m2.988s 
40+ user	0m2.176s 
41+ sys	0m0.812s 
42+ ``` 
43+ 3444To show a more practical example where you can't just cast it:
3545
3646``` 
3747time python list-append-loop2.py 
38- ``` 
3948
4049real	0m29.756s 
4150user	0m28.875s 
4251sys		0m0.880s 
52+ ``` 
4353
4454
4555``` 
4656time python list-comp2.py 
47- ``` 
4857
4958real	0m21.932s 
5059user	0m21.031s 
5160sys		0m0.900s 
61+ ``` 
5262
5363In this practical example, we see that the list comprehension finished
5464in about 2/3 of the time it took the for loop append() method, still
0 commit comments