in the experiment above the statement that we are timing is the function call to test ()test ()and so on the setup statement may look very strange to youso let us consider it in more detail you are probably very familiar with the fromimport statementbut this is usually used at the beginning of python program file in this case the statement from __main__ import test imports the function test from the __main__ namespace into the namespace that timeit sets up for the timing experiment the timeit module does this because it wants to run the timing tests in an environment that is uncluttered by any stray variables you may have createdthat may interfere with your function' performance in some unforeseen way from the experiment above it is clear that the append operation at milliseconds is much faster than concatenation at milliseconds in the above experiment we also show the times for two additional methods for creating listusing the list constructor with call to range and list comprehension it is interesting to note that the list comprehension is twice as fast as for loop with an append operation one final observation about this little experiment is that all of the times that you see above include some overhead for actually calling the test functionbut we can assume that the function call overhead is identical in all four cases so we still get meaningful comparison of the operations so it would not be accurate to say that the concatenation operation takes milliseconds but rather the concatenation test function takes milliseconds as an exercise you could test the time it takes to call an empty function and subtract that from the numbers above now that we have seen how performance can be measured concretely you can look at table to see the big- efficiency of all the basic list operations after thinking carefully about table you may be wondering about the two different times for pop when pop is called on the end of the list it takes ( but when pop is called on the first element in the list or anywhere in the middle it is (nthe reason for this lies in how python chooses to implement lists when an item is taken from the front of the listin python' implementationall the other elements in the list are shifted one position closer to the beginning this may seem silly to you nowbut if you look at table you will see that this implementation also allows the index operation to be ( this is tradeoff that the python implementors thought was good one as way of demonstrating this difference in performance let us do another experiment using the timeit module our goal is to be able to verify the performance of the pop operation on list of known size when the program pops from the end of the listand again when the program pops from the beginning of the list we will also want to measure this time for lists of different sizes what we would expect to see is that the time required to pop from the end of the list will stay constant even as the list grows in sizewhile the time to pop from the beginning of the list will continue to increase as the list grows the code below shows one attempt to measure the difference between the two uses of pop as you can see from this first examplepopping from the end takes millisecondswhereas popping from the beginning takes milliseconds for list of two million elements this is factor of there are couple of things to notice about this code the first is the statement from __main__ import $xalthough we did not define function we do want to be able to use the list object in our test this approach allows us to time just the single pop statement and get the most accurate measure of the time for that single operation because the timer repeats algorithm analysis