1#tuples and lists are the same thing, but a tuple cannot be changed
2tup = (1,'string',True)
3lst = ['hiya',23545,None]
1mylist : list = [] # <-- a list variable can be defined either as [] or <varname> : list
2mytuple : tuple = () # <-- a tuple variable can be defined either as () or <varname> : tuple
1# compare the size
2import sys
3my_list = [0, 1, 2, "hello", True]
4my_tuple = (0, 1, 2, "hello", True)
5print(sys.getsizeof(my_list), "bytes")
6print(sys.getsizeof(my_tuple), "bytes")
7
8# compare the execution time of a list vs. tuple creation statement
9import timeit
10print(timeit.timeit(stmt="[0, 1, 2, 3, 4, 5]", number=1000000))
11print(timeit.timeit(stmt="(0, 1, 2, 3, 4, 5)", number=1000000))
12
1import timeit
2print(timeit.timeit('x=(1,2,3,4,5,6,7,8,9)', number=100000))
3
4print(timeit.timeit('x=[1,2,3,4,5,6,7,8,9]', number=100000))