I am just learning the threading module of python, threading implementation of a test code as below takes more time compared to the sequential implementation. Am I missing an underlying concept of threading in python?
from time import sleep, perf_counter from threading import Thread def task(id): print(f'Starting the task {id}...') for i in range(1, 1000): for j in range(1, 1000): b=(i**2)/(i*j**3) print(f'The task {id} completed') ############## sequential ############## start_time = perf_counter() for n in range(1, 11): task(n) end_time = perf_counter() print(f'sequential took {end_time- start_time: f} second(s) to complete.') ##########E Multi-threading ########## start_time = perf_counter() threads = [] for n in range(1, 11): t = Thread(target=task, args=(n,)) threads.append(t) t.start() for t in threads: t.join() end_time = perf_counter() print(f'multi-threaded took {end_time- start_time: f} second(s) to complete.')