The following code prints False
on python27 and True
on python36 on my Mac.
from threading import Thread
def make_huge_list(amount):
my_list = []
def add_num(num):
my_list.append(num)
threads = [Thread(target=add_num, args=(i,)) for i in range(amount)]
for t in threads:
t.start()
for t in threads: t.join()
return my_list
if __name__ == '__main__':
# check the output is ordered
print(make_huge_list(100000) == list(range(100000)))
I know that GIL improvements were added in python3 for better scheduling/fairness. I'm puzzled on how/why this codes prints True
on python36.