What is the underlying data structure of the three common python data structure: list, tuple and set?
I heard from someone that list in python is implemented as linked list. How about tuple and set? To be specific, how is the true memory of the computer allocated for their implementation?
I tried to time the task of looking for a number in the collection of number and found that tuple shows the best performance. Why is that the case?
from timeit import timeit
timeit('238478 in (x for x in range(1000000))', number = 100) #time ~ 2s
timeit('238478 in {x for x in range(1000000)}', number = 100) #time ~ 7s
timeit('238478 in [x for x in range(1000000)]', number = 100) #time ~ 7s
I tried to read the documentation but it doesn't describe the underlying architecture.
Edit: I want to study the speed of Python vs other languages. For example, array in C surely outperform list in Python. But what if I compare tuple vs array? To study these, I would like to understand more on how these data structures in Python are working in the computer.