@@ -0,0 +1,1083 @@
+import multiprocessing as mp%0Aimport threading as td%0Aimport time%0A%0Adef job(q):%0A    res = 0%0A    for i in range(1000000):%0A        res += i+i**2+i**3%0A    q.put(res) # queue%0A%0Adef multicore():%0A    q = mp.Queue()%0A    p1 = mp.Process(target=job, args=(q,))%0A    p2 = mp.Process(target=job, args=(q,))%0A    p1.start()%0A    p2.start()%0A    p1.join()%0A    p2.join()%0A    res1 = q.get()%0A    res2 = q.get()%0A    print('multicore:' , res1+res2)%0A%0Adef normal():%0A    res = 0%0A    for _ in range(2):%0A        for i in range(1000000):%0A            res += i+i**2+i**3%0A    print('normal:', res)%0A%0Adef multithread():%0A    q = mp.Queue()%0A    t1 = td.Thread(target=job, args=(q,))%0A    t2 = td.Thread(target=job, args=(q,))%0A    t1.start()%0A    t2.start()%0A    t1.join()%0A    t2.join()%0A    res1 = q.get()%0A    res2 = q.get()%0A    print('multithread:', res1+res2)%0A%0Aif __name__ == '__main__':%0A    st = time.time()%0A    normal()%0A    st1= time.time()%0A    print('normal time:', st1 - st)%0A    multithread()%0A    st2 = time.time()%0A    print('multithread time:', st2 - st1)%0A    multicore()%0A    print('multicore time:', time.time()-st2)%0A%0A

create multiprocessing4