On Mon, Jan 26, 2015 at 11:23 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > $ python3 -m timeit 't = (1000, 2000, 3000)' > 100000000 loops, best of 3: 0.0147 usec per loop > $ python3 -m timeit 't = [1000, 2000, 3000]' > 10000000 loops, best of 3: 0.0678 usec per loop > $ python3 -m timeit 't = tuple(range(10000))' > 10000 loops, best of 3: 183 usec per loop > $ python3 -m timeit 't = list(range(10000))' > 10000 loops, best of 3: 174 usec per loop > $ python3 -m timeit 't = tuple(range(10000000))' > 10 loops, best of 3: 323 msec per loop > $ python3 -m timeit 't = list(range(10000000))' > 10 loops, best of 3: 306 msec per loop > > This is probably a result of the use of freelists to avoid > reallocating the tuple objects, though. I don't see any substantial > difference in access time:
Whoops. Actually it's a result of the 3-element tuple being a constant in the code object. If we use the constructor, the difference mostly goes away. $ python3 -m timeit 't = tuple(range(1000, 4000, 1000))' 1000000 loops, best of 3: 0.559 usec per loop $ python3 -m timeit 't = list(range(1000, 4000, 1000))' 1000000 loops, best of 3: 0.585 usec per loop -- https://mail.python.org/mailman/listinfo/python-list